Repository navigation
feat(runtime): invoke_agent_streaming keeps the typed HostedError on the streaming path - #261
Conversation
Add a new `invoke_agent_streaming` method to `AgentHarness` that runs an agent through the streaming model path while returning typed `HostedError` on failure. This preserves the specific error kind from per-model-call timeouts, limits, and provider failures, unlike the public stream's terminal `Failed` item which sanitizes all failures to a single fixed string. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
When the test runtime is not available, the harness now returns a clear error instead of panicking. This improves robustness in environments where the runtime may not be initialized. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
Changed the retry policy in the streaming timeout test from `RetryPolicy::none()` to `RetryPolicy::default().with_max_attempts(1)` to ensure the test exercises the same retry logic as production code while still limiting to a single attempt. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
Tiny Sweeper review
Last completed reportTiny Sweeper reviewTiny Sweeper reviewed this change across 6 lane(s) and found 0 active actionable finding(s). Detailed lane evidence and any incomplete work are listed below. State: Incomplete Review snapshot
Completeness: Incomplete What changedThe review could not produce a supported behavioral summary; inspect the cited changed surface and lane details below. FeaturesNone identified with supported citations. TestsNo supported feature-to-test mapping was produced. Test execution is not inferred. FindingsNo active actionable findings. Could not review: crates/tinyagents-harness/src/runtime/agent.rs, crates/tinyagents-harness/src/runtime/test.rs Before merge
How this fits togetherflowchart LR
n0["...call_limit_bounds_initial_host_resolution<br/>changed"]:::changed
n1["new"]:::impacted
n2["invoke_agent"]:::impacted
n3["host"]:::impacted
n4["...ions_finalize_the_actual_partial_run_once"]:::impacted
n0 -->|calls| n1
n0 -->|tests| n1
n0 -->|calls| n2
n0 -->|tests| n2
n0 -->|uses| n3
n3 -->|calls| n1
n3 -->|tests| n1
n4 -->|calls| n1
n4 -->|tests| n1
n4 -->|calls| n2
n4 -->|tests| n2
classDef changed fill:#0d4429,stroke:#238636,color:#e6edf3
classDef impacted fill:#161b22,stroke:#6e7681,color:#c9d1d9
classDef flagged fill:#5a1e02,stroke:#d93f0b,color:#ffffff
classDef blocking fill:#67060c,stroke:#f85149,color:#ffffff
Agent review detailscritique
security
tests
commits
description
e2e
Evidence and run details
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughAdds ChangesHosted streaming invocation
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Feature Suggested reviewers: Merge Risk: ⚪ Minimal · up to This adds a public method that returns typed hosted errors from the streaming path, with a timeout regression test. No merge-blocking risk was identified. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The streaming API shares authorization and sanitized error handling with the other public invocation APIs. No specific security regression was established, but the reviewed baseline and interruption/retry contracts remain partly uncertain. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
A rabbit watches tokens stream, Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4583fd645c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| /// `Failed` item is sanitized to one fixed string for every failure, so a | ||
| /// per-model-call timeout, a limit, and a provider failure become | ||
| /// indistinguishable. This entry point keeps the kind. | ||
| pub async fn invoke_agent_streaming( |
There was a problem hiding this comment.
Document the typed hosted streaming entry point
Add this method to the hosted-invocation documentation. The canonical crates/tinyagents-harness/src/runtime/README.md still lists only invoke_agent and invoke_agent_stream, while docs/modules/harness/hosting.md demonstrates only the unary API, so users seeking streaming execution with a terminal result are not told that this typed-error alternative exists or why it should replace draining the sanitized stream. This leaves the module guides out of sync with the new public API.
AGENTS.md reference: AGENTS.md:L78-L82
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
tinysweeper found nothing blocking, but could not review everything, so this is not an approval: crates/tinyagents-harness/src/runtime/agent.rs, crates/tinyagents-harness/src/runtime/test.rs.
$0.0062 · 50,530 in / 14,206 out · 12,288 cached (24%) · ladder/vectors, deepseek/deepseek-v4-flash · 442 embedded
tests: $0.0045 · 43,176 in / 8,305 out · 12,288 cached (28%) · deepseek/deepseek-v4-flash
description: $0.0011 · 4,596 in / 3,872 out · 0 cached (0%) · deepseek/deepseek-v4-flash
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Summary
AgentHarness::invoke_agent_streaming, a public wrapper over the existing crate-privateinvoke_agent_streaming_with_capabilities. It runs a hosted turn on the streaming model path and returnsResult<AgentRun, HostedError>, exactly likeinvoke_agent, with the closedHostedErrorKind, the fixed per-kind message and the partial run.max_model_call_ms, returnsHostedErrorKind::Timeout.Problem
A host that wants streaming (model deltas and delta middleware) but only the terminal outcome has to drain
invoke_agent_stream. That public stream sanitizes its terminalAgentStreamItem::Failedto the single stringhosted agent invocation failedfor every failure (sanitize_hosted_stream_item). A per-model-call timeout (CallTimeout), a run timeout, a limit and a provider failure are therefore indistinguishable to the host, even thoughHostedErrorKindexists precisely so a host can tell them apart without reading raw error text. OpenHuman hit this as a wedged model call surfacing as a genericinferenceerror instead ofturn_timeout(tinyhumansai/openhuman#6375).Solution
Expose the typed streaming driver that recursive delegation already uses. No sanitization contract changes: the public stream keeps its fixed string, and
HostedError.messageis still a fixed string per kind.Tests
cargo test -p tinyagents-harness --lib runtime::(47 passed, including the newinvoke_agent_streaming_preserves_the_timeout_kind_of_a_stalled_model_call)cargo clippy -p tinyagents-harness --all-targets -- -D warningsSummary by CodeRabbit