Implement #8: Production and Deployment#44
Open
yagop wants to merge 1 commit into
Open
Conversation
Chapter 8 plus its examples/08-production/ samples: the SDK error-class ladder with request-id logging, manual backoff with maxRetries: 0, a concurrency-capped queue reading rate-limit headers, a per-session cost tracker (incl. cache_read_input_tokens), a secret-validated Bun webhook server, and a multi-stage non-root Bun Dockerfile. Wires the chapter into the sidebar and README. Verified the cutoff-sensitive surface against the installed SDK: APIConnectionTimeoutError (not APITimeoutError), .withResponse() (not withRawResponse.create), and the anthropic-ratelimit-* header names. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
14 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #8
Chapter 8 hardens the agent for production: the SDK error hierarchy, retries/timeouts, rate-limit-aware concurrency, observability + cost, and deployment (a webhook server + Dockerfile). Authored single-pass; the cutoff-sensitive error/retry surface was verified against the installed SDK.
Definition of done
chapters/08-production.md,<=120lines,<=4main-line H2s plus a closer<<< @/examples/08-production/file.tsmaxRetries: 0gotcha lives in a:::warning, not a code comment); reader addressed as "you"; intro + sections open warm@anthropic-ai/sdksurface; ASCII punctuation only:::detailsasideREADME.mdand the.vitepress/config.tssidebar;bun x vitepress buildpasses27-33lines (mostly within<=35; the skill cap is<=100)Cutoff-sensitive corrections (issue text was outdated; verified against the installed SDK
.d.ts)APITimeoutError->APIConnectionTimeoutError(the real exported class, extendsAPIConnectionError).client.messages.withRawResponse.create(...)->.create(...).withResponse()(returns{ data, response, request_id }) /.asResponse().x-ratelimit-remaining-requests->anthropic-ratelimit-requests-remaining(Anthropic's header name).APIErrorthe request id iserror.requestID(camelCase), while.withResponse()returnsrequest_id(snake_case).Verification (run live)
Chapter:
wc -l-> 61;grep -c '^## '-> 4.tsc --noEmitclean;vitepress buildpasses (all six snippets resolve, including theDockerfile).ok request_id=n/a: Hi there, friend, then the malformed (empty-messages) call hits thebad request (400)branch.{ maxRetries: 0 }; theretry-afterbackoff path is in place.input=25 output=41 cache_read=0,estimated cost: $0.00069.chat 1: pong) and returnedok; a POST without the secret got403.USER bun, env-only secrets); notdocker build-tested - Docker isn't available in this environment.Notes / gateway flags
request_id: nulland omitsanthropic-ratelimit-*headers (real Anthropic provides both), so the request-id logs printn/aand the limiter's remaining-count staysInfinity. The sample code reads the real fields and is correct against Anthropic.Review flags
None.
🤖 Generated with Claude Code