mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-26 18:15:13 +00:00
fix(plugins): expose effective context budget in hooks
Add optional context budget/source/reference metadata to plugin hook contexts plus llm_output and sanitized model_call_* hook events. Thread the existing resolved context-window info through Pi embedded runs, CLI harness runs, and Codex app-server hook emission so plugins can observe the effective budget after agent/model/config caps. Document the metadata and cover the CLI, Pi, Codex app-server, and model-call paths with focused tests. Fixes #64327.
This commit is contained in:
@@ -114,7 +114,7 @@ observation-only.
|
||||
|
||||
- `model_call_started` / `model_call_ended` - observe sanitized provider/model call metadata, timing, outcome, and bounded request-id hashes without prompt or response content
|
||||
- `llm_input` - observe provider input (system prompt, prompt, history)
|
||||
- `llm_output` - observe provider output
|
||||
- `llm_output` - observe provider output, usage, and the resolved `contextTokenBudget` when available
|
||||
|
||||
**Tools**
|
||||
|
||||
@@ -287,7 +287,11 @@ that should not receive raw prompts, history, responses, headers, request
|
||||
bodies, or provider request IDs. These hooks include stable metadata such as
|
||||
`runId`, `callId`, `provider`, `model`, optional `api`/`transport`, terminal
|
||||
`durationMs`/`outcome`, and `upstreamRequestIdHash` when OpenClaw can derive a
|
||||
bounded provider request-id hash.
|
||||
bounded provider request-id hash. When the runtime has resolved context-window
|
||||
metadata, the hook event and context also include `contextTokenBudget`, the
|
||||
effective token budget after model/config/agent caps, plus
|
||||
`contextWindowSource` and `contextWindowReferenceTokens` when a lower cap was
|
||||
applied.
|
||||
|
||||
`before_agent_finalize` runs only when a harness is about to accept a natural
|
||||
final assistant answer. It is not the `/stop` cancellation path and does not
|
||||
|
||||
Reference in New Issue
Block a user