Redesign client API: query/abort, structured output, and secret redaction#7
Merged
vijit-lark merged 14 commits intomainfrom Mar 15, 2026
Merged
Redesign client API: query/abort, structured output, and secret redaction#7vijit-lark merged 14 commits intomainfrom
vijit-lark merged 14 commits intomainfrom
Conversation
…ation API Instead of passing an async polling callback to invoke(), clients now call client.abort() imperatively from any coroutine to cancel a running invocation. Uses an internal asyncio.Event that is checked on each message and reset at the start of each invoke() call. Made-with: Cursor
Replace on_result_message/on_error_message callbacks with a simpler await-based API: invoke now returns the result message and raises AgentRuntimeError on runtime errors. Made-with: Cursor
Introduce QueryOptions dataclass that consolidates InvocationMessage fields and runtime params. The new query(prompt, options) method builds the wire-format InvocationMessage internally. Made-with: Cursor
query() now always returns ResultMessageInterface; callers can validate into custom subclasses themselves. Made-with: Cursor
…ted results
Make output_format_json_schema_str optional across the wire protocol,
Python client, and TS runtime. When omitted, the runtime returns a text
response instead of structured output. Both result types carry an
explicit type discriminator ("text" | "structured_output") for safe
dispatch on the client side. Handlers now validate that the result
variant matches expectations and throw on mismatches.
Made-with: Cursor
Move text/structured_output from top-level ResultMessage fields into a nested `data` field with a `type` discriminator. Remove metadata from result variants (stays on ResultMessageInterface). Change query() to return ResultMessageInterface directly. Remove QueryResult type alias. Made-with: Cursor
Separate the public API type from the wire-format type: query() now returns QueryResult (data + metadata) instead of ResultMessageInterface, avoiding exposure of the message_type field to callers. Made-with: Cursor
Command no longer carries env; CommandHandler receives secrets explicitly from the invocation message's secrets_to_redact field instead. Made-with: Cursor
Made-with: Cursor
- root: replace old invoke() example with query() API, fix server.start() → startListening() - runtime: fix server.start() → startListening(), remove nonexistent env field from AgentInvocation, update AgentResult to discriminated union, add type field to custom handler example - python client: fix install command to runtimeuse-client, fix imports to runtimeuse_client Made-with: Cursor
Made-with: Cursor
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.
Summary
invoke→querywith a clearerprompt+QueryOptionssignature, and replaced theis_cancelledcallback with a simplerclient.abort()method.querynow returns aQueryResultdirectly and raises on errors instead of requiring manual result inspection.TextResult|StructuredOutputResult) underresult.data, driven by the optionaloutput_format_json_schema_strparameter.envfromCommand, addedsecrets_to_redactto strip sensitive values from agent logs and responses.server.start()→server.startListening()for clarity.QueryOptionsfields, bumped version to 0.5.0.