Skip to content

docs(agent): fix README/API drift — ctx.local, StateAccessor, stream semantics#62

Merged
LukasParke merged 1 commit into
mainfrom
docs/readme-api-drift
Jul 15, 2026
Merged

docs(agent): fix README/API drift — ctx.local, StateAccessor, stream semantics#62
LukasParke merged 1 commit into
mainfrom
docs/readme-api-drift

Conversation

@LukasParke

@LukasParke LukasParke commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Three README sections document APIs that don't exist (each cost real debugging time building production agents on the SDK):

  1. Tool Context: ctx?.context.… → actual API is ctx.local
  2. Conversation State: state as mutable value + (await getResponse()).state → actual API is a StateAccessor ({load, save}), read via result.getState()
  3. Streams: getToolStream() yields argument deltas (+ generator preliminary_result), not execution events — those are on getFullResponsesStream()

Corrected against source; added a streams cheat-sheet table; StateAccessor example notes plain-JSON serverless resume. Docs-only. Related: SDK-423/SDK-307.


Open in Devin Review

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@perry-the-pr-reviewer perry-the-pr-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perry's Review

Verdict: 💬 Comments / questions

(Posting as COMMENT, not APPROVE: the maintainer GitHub App lacks pull_requests:write on OpenRouterTeam, so Perry cannot record a formal approval here. Content-wise this is an LGTM — docs-only, no action items.)

Details

Accurate docs-only fix. I verified all three drift corrections against source at the PR head:

  • ctx.local — the tool call context exposes local (a getter on the merged context object); the old ctx.context example was simply wrong. Corrected.
  • StateAccessor + getState() — the state option takes a { load, save } accessor, and state is read via getState(). The old (await getResponse()).state was fiction — getResponse() returns an OpenResponsesResult with no state field. Corrected, and the plain-JSON serverless-resume note is accurate.
  • Stream semanticsgetToolStream() yields delta argument events plus preliminary_result for generator tools; execution results (tool.result / tool.call_output) ride getFullResponsesStream(). Both event names exist in source and the new cheat-sheet table matches the implementation.

The leftover createInitialState import in the Subpath Exports section is correct, not stale — that subpath export still exists. No changes requested.

@LukasParke
LukasParke merged commit 1362232 into main Jul 15, 2026
6 checks passed
@LukasParke
LukasParke deleted the docs/readme-api-drift branch July 15, 2026 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant