Conversation
- retry: ExecutionTimeoutError is now retried; GuardrailValidationError warns before re-raise; an explicit per-call retry= overrides the agent-level setting (was unreachable dead code) - concurrency: isolate per-run state in a ContextVar (new agent/run_state.py) so concurrent do_async/astream no longer clobber each other's run_id / output / tool counts - chat: a failed invoke latches SessionState.ERROR; reopen() recovers non-destructively (history + cumulative duration preserved); invoking a closed session raises SessionClosedError - usage: tool_calls are counted into the registry from ModelResponse.tool_calls - memory: num_last_messages groups history by user-turn boundary, so the limit holds through tool round-trips - heartbeat: execute_heartbeat / aexecute_heartbeat gain a print= opt-in (silent by default) - refactor: reuse the ModelResponse.tool_calls property instead of inline ToolCallPart filtering - tests: unit tests for every fix; env-based smoke model selection (conftest + helper); concurrency + chat-lifecycle smoke tests; smoke fixes pinning model-specific tests - docs: sync explanation docs (agent / chat / memory / utils)
…ed cost) - MemorySaveStep now self-finalizes in a finally block like every other non-streaming step, so execution_stats counts all steps (24/24 instead of 23/24) and records step_statuses['memory_save']. - Record tool execution time into the usage registry via a new kind='tool' entry (record_tool_execution_time), wired through the single chokepoint AgentRunOutput.add_tool_execution_time, so Agent.usage.tool_execution_time reflects real tool wall time instead of staying 0. - Price the per-call cost panels cache-aware (get_estimated_cost_from_usage) so the displayed Estimated Cost matches the cache-aware chat.usage.cost instead of charging cached input at full rate. - Sync the step-finalization note in explanation/agent/agent.md; add unit and smoke regression tests.
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.
ExecutionTimeoutErroris now retried;GuardrailValidationErrorwarns before re-raise; an explicit per-callretry=overrides the agent-level setting (previously unreachable dead code).run_id/ output / tool counts) isolated in aContextVar(agent/run_state.py); concurrentdo_async/astreamon one agent no longer clobber each other.SessionState.ERROR;reopen()recovers non-destructively (history + cumulative duration); invoking a closed session raisesSessionClosedError.tool_callsare counted into the usage registry (fromModelResponse.tool_calls).num_last_messagesgroups history by user-turn boundary, so the limit holds through tool round-trips.execute_heartbeat/aexecute_heartbeatgain aprint=opt-in (silent by default).ModelResponse.tool_callsproperty instead of inlineToolCallPartfiltering (recorder + 3 call sites).Usage-metrics accuracy
Three pre-existing telemetry/display defects (low severity, no wrong outputs), fixed and regression-tested:
MemorySaveStepwas the only non-streaming step that never self-finalized, so runs logged23/24 stepsand droppedstep_statuses['memory_save']. It now finalizes in afinallylike every sibling →24/24.Agent.usage.tool_execution_timestayed0. Now recorded as akind="tool"registry entry viarecord_tool_execution_time, through the singleAgentRunOutput.add_tool_execution_timechokepoint (no double-count).upsonic_execution_timeis unchanged (the same elapsed is added to bothdurationandtool_execution_time).chat.usage.cost. Panels now price cache-aware viaget_estimated_cost_from_usage(backward-compatible: no cache tokens → identical output).