fix(tinyagents-audit): execute §5 fix-in-place items — provider diagnostic, anchor coupling, dead-read clarifications#4542
Conversation
…ostic The default `Provider::stream_chat_with_history` built its error message from a hardcoded `let provider_name = "unknown"`, emitting the useless "unknown does not support streaming". The trait already exposes `telemetry_provider_id()` (every concrete provider overrides it), and the method has `&self`, so the real slug was reachable but unused. Use it, and add a co-located test asserting the diagnostic names the provider and no longer says "unknown". Fix-in-place item from docs/tinyagents-port-plan.md §5 (inference/). Claude-Session: https://claude.ai/code/session_01LHbWHHV8MAFsv8aLi9XSbB
The doc-comment describing the slug-collision guard sat above `empty_integration_description_falls_back_to_generic_label` (which tests the empty-description fallback). Move it to the test it actually describes, `duplicate_sanitised_slug_drops_later_collisions`. Test bodies and behavior are unchanged. Fix-in-place item from docs/tinyagents-port-plan.md §5 (tools/). Claude-Session: https://claude.ai/code/session_01LHbWHHV8MAFsv8aLi9XSbB
…jection filter config_rejection.rs's Sentry before_send phrase list hardcoded the literal "resolved to an empty model id" that also lives in factory.rs's `NO_MODEL_CONFIGURED_ANCHOR`. A round-trip test guarded against drift; referencing the const directly makes them compile-coupled so they can never diverge. No behavior change. Fix-in-place item from docs/tinyagents-port-plan.md §5 (inference/). Claude-Session: https://claude.ai/code/session_01LHbWHHV8MAFsv8aLi9XSbB
recommend_tier reads device RAM but always returns MVP_MAX_TIER; the recommend_tier_scales_with_ram test pins this non-scaling contract. Add a comment documenting that the cap is intentional for the MVP (RAM is read only for the diagnostic log) so the function stops reading as dead logic. Behavior unchanged; RAM->tier scaling deferred until higher tiers ship. Fix-in-place item from docs/tinyagents-port-plan.md §5 (inference/). Claude-Session: https://claude.ai/code/session_01LHbWHHV8MAFsv8aLi9XSbB
The NotOwned arm in handle_subagent_steer is unreachable on the trusted RPC steer_control path (which performs no ownership check), but the variant is not dead overall: the agent-tool running_subagents::steer path enforces ownership and returns NotOwned (with a passing test). Reword the comment to point at the live path and the Phase 4 SteeringRegistry ownership consolidation, resolving the "dead code" misread. Fix-in-place item from docs/tinyagents-port-plan.md §5 (agent_orchestration/). Claude-Session: https://claude.ai/code/session_01LHbWHHV8MAFsv8aLi9XSbB
AgentOnly has three real constructors (agent_memory, rlm, subconscious), so the dead_code allow is stale. Remove it and document that no execution path currently gates on AgentOnly (it behaves like All today); the AgentOnly-vs-All reconciliation is deferred to the Phase 2 tool-model work. Fix-in-place item from docs/tinyagents-port-plan.md §5 (tools/). Claude-Session: https://claude.ai/code/session_01LHbWHHV8MAFsv8aLi9XSbB
📝 WalkthroughWalkthroughThis PR consists of documentation and comment clarifications across several files, plus one behavioral fix: the default ChangesComments, Diagnostics, and Shared Constants
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Possibly related PRs
Suggested labels: `bug` Suggested reviewers: `sanil-23`, `M3gA-Mind` Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
Audit against current code found the arm is not globally dead: the agent-tool running_subagents::steer path enforces parent ownership and returns NotOwned (with a passing test). Only the trusted RPC steer_control path skips the check, making the arm unreachable there. Reword §5 to reflect this and point at the Phase 4 SteeringRegistry consolidation. The matching code comment is clarified in fix/tinyagents-audit-fixes (PR tinyhumansai#4542). Claude-Session: https://claude.ai/code/session_01LHbWHHV8MAFsv8aLi9XSbB
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/openhuman/inference/provider/traits.rs (1)
732-739: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueStale comment and minor format-string inconsistency.
Line 732's comment ("we need to convert to owned strings") was accurate when the code literally did
"unknown".to_string(); now thatprovider_namecomes fromtelemetry_provider_id()(already an ownedString), the rationale is stale. Also, line 739'sformat!uses positional args while nearby code in this file (e.g. line 535) uses inlined args ({e}style).♻️ Optional cleanup
- // For default implementation, we need to convert to owned strings // This is a limitation of the default implementation. Name the real // provider via its telemetry slug so the diagnostic is actionable // instead of the useless literal "unknown". let provider_name = self.telemetry_provider_id(); // Create a single empty chunk to indicate not supported - let chunk = StreamChunk::error(format!("{} does not support streaming", provider_name)); + let chunk = StreamChunk::error(format!("{provider_name} does not support streaming"));🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/openhuman/inference/provider/traits.rs` around lines 732 - 739, Update the default streaming-not-supported path in traits.rs by removing the stale comment about converting to owned strings now that provider_name is sourced from telemetry_provider_id(), and make the StreamChunk::error formatting consistent with the rest of the file by using the inline variable style instead of a positional format argument. Keep the fix localized to the default implementation that builds provider_name and the error chunk.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/openhuman/inference/provider/traits.rs`:
- Around line 732-739: Update the default streaming-not-supported path in
traits.rs by removing the stale comment about converting to owned strings now
that provider_name is sourced from telemetry_provider_id(), and make the
StreamChunk::error formatting consistent with the rest of the file by using the
inline variable style instead of a positional format argument. Keep the fix
localized to the default implementation that builds provider_name and the error
chunk.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9b6bbb06-201b-4d2d-8dc1-5e7e389f85b5
📒 Files selected for processing (7)
src/openhuman/agent_orchestration/subagent_control.rssrc/openhuman/inference/presets.rssrc/openhuman/inference/provider/config_rejection.rssrc/openhuman/inference/provider/traits.rssrc/openhuman/inference/provider/traits_tests.rssrc/openhuman/tools/orchestrator_tools.rssrc/openhuman/tools/traits.rs
Summary
Execute the safe, behavior-preserving §5 "bugs, gaps & improvements found during the audit" items from
docs/tinyagents-port-plan.md— the fix-in-place candidates independent of the port itself. Six focused commits:Provider::stream_chat_with_historynamed its unsupported-streaming error"unknown"— now uses the trait'stelemetry_provider_id()so the diagnostic names the real provider (+ test).before_sendrejection filter hardcoded a literal that duplicatesfactory::NO_MODEL_CONFIGURED_ANCHOR— reference the const directly so they compile-couple (was test-guarded only).recommend_tierreads RAM but always returnsMVP_MAX_TIER— documented as the intentional MVP cap (test already pins the non-scaling contract) so it stops reading as dead logic.SteerError::NotOwnedis not dead — the agent-toolsteerpath enforces ownership and returns it; only the trusted RPC path skips the check.#[allow(dead_code)]onToolScope::AgentOnly(it has three real constructors) and documented that it currently behaves likeAll.orchestrator_tools.rsto the slug-collision test it actually describes.Problem
The port-plan audit catalogued a set of localized defects and misleading/dead-reading code in
inference/,tools/, andagent_orchestration/(plan §5). They are independent of the multi-phase crate consolidation and worth fixing in place — several would otherwise be deleted-in-place with their host anyway, but until then they mislead readers (e.g. a"unknown does not support streaming"diagnostic, arecommend_tierthat looks broken, aNotOwnedarm that looks dead).Solution
Only the behavior-preserving subset is applied here; each genuine behavior/API decision the audit raised is deliberately deferred to its planned phase and left documented, not guessed:
recommend_tier(would violate the MVP cap) — not implemented.SteerError::NotOwned(would change the JSON-RPC payload/trust model, which the plan forbids during the port) — deferred to Phase 4'sSteeringRegistry.ToolScope::AgentOnlyvsAllreconciliation andis_concurrency_safeadoption (needs upstream tinyagents parallel dispatch) — deferred to Phase 2 / upstream.The one observable change (the streaming-unsupported diagnostic text) is covered by a new co-located unit test asserting it names the provider and no longer says
"unknown".Submission Checklist
default_stream_chat_with_history_names_provider_when_unsupportedcovers the only behavior change (diagnostic text). The remaining commits are doc/annotation/refactor with no behavior delta.provider_name = self.telemetry_provider_id()) is directly exercised by the new test; the rest are comments/annotations. Full validation deferred to CI.N/A: no user-facing feature rows(internal diagnostics/comments/refactors).## Related—N/A.N/A: no release-cut surface change.N/A(audit fix-in-place batch; see## Related).Impact
[local_ai] recommended model tiercontext are now more actionable; theconfig_rejectionanchor can no longer silently drift from Sentry's filter.NotOwnedandAgentOnlydecisions that would touch trust/gating are deferred).Related
docs/tinyagents-port-plan.mdaudit; not a tracked issue)AI Authored PR Metadata (required for Codex/Linear PRs)
Linear Issue
Commit & Branch
fix/tinyagents-audit-fixes1dfef9d963889a27ee8730a07f04d5cd612d1f20Validation Run
pnpm --filter openhuman-app format:check— N/A (noapp/srcchanges)pnpm typecheck— N/A (no TypeScript changes)cargo fmtapplied.cargo check --librun locally on the branch (see notes);cargo fmtclean.Validation Blocked
command:fullcargo testsuiteerror:none — deferred to GitHub runners per the requester; local validation bounded tocargo check --lib+cargo fmt.impact:CI (CI Lite on this PR) is the authoritative gate.Behavior Changes
Parity Contract
recommend_tiernon-scaling contract still pinned by its test;config_rejectionanchor still guarded by thefactory_tests.rsround-trip.Duplicate / Superseded PR Handling