feat(agent): identify response inputs on model request start (#6721)

This commit is contained in:
chengyongru authored and GitHub committed 2026-11-19 15:07:22 +08:00
1 parent 32bba3a16c
commit 488b657ee1
9 files changed
+102 -4

No files matched your search

+2
View File
@@ -260,6 +260,8 @@ class ModelRequestState:
request_run_id: str = field(default_factory=lambda: uuid4().hex)
request_sequence: int = 0
request_usage: LLMUsage | None = None
# Current response targets, shared by requests that recover the same answer.
response_input_ids: tuple[str, ...] = ()
# Reported usage per runner round; recovery requests update the same slot.
recent_round_usages: list[LLMUsage | None] = field(default_factory=list)
+2
View File
@@ -500,6 +500,7 @@ class AgentRunner:
had_injections = True
await end_length_segment(interrupted=drained_before_request)
response_input_ids = self._response_input_ids(messages)
request_state.response_input_ids = response_input_ids
if spec.events.accepts(ResponseInputsEvent):
await spec.events.emit(ResponseInputsEvent(response_input_ids))
context = AgentHookContext(
@@ -993,6 +994,7 @@ class AgentRunner:
round_usages=tuple(usage for usage in state.recent_round_usages if usage is not None),
context_window_tokens=spec.runtime.context_window_tokens,
request_usage=request_usage,
response_input_ids=state.response_input_ids if phase == "started" else (),
))
try: