Skip to content

Redesign client API: query/abort, structured output, and secret redaction#7

Merged
vijit-lark merged 14 commits intomainfrom
vd-20260313-1635
Mar 15, 2026
Merged

Redesign client API: query/abort, structured output, and secret redaction#7
vijit-lark merged 14 commits intomainfrom
vd-20260313-1635

Conversation

@vijit-lark
Copy link
Copy Markdown
Contributor

Summary

  • Redesigned the client interface — renamed invokequery with a clearer prompt + QueryOptions signature, and replaced the is_cancelled callback with a simpler client.abort() method. query now returns a QueryResult directly and raises on errors instead of requiring manual result inspection.
  • Added structured output support — results are a discriminated union (TextResult | StructuredOutputResult) under result.data, driven by the optional output_format_json_schema_str parameter.
  • Introduced secret redaction — removed env from Command, added secrets_to_redact to strip sensitive values from agent logs and responses.
  • Server-side renameserver.start()server.startListening() for clarity.
  • Documentation & polish — updated READMEs for both packages to match the new APIs, added inline doc-comments to QueryOptions fields, bumped version to 0.5.0.

…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
- 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
@vijit-lark vijit-lark merged commit b5066ac into main Mar 15, 2026
5 checks passed
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