📡 live session presence: providers push status + context tokens to /sessions - #192
📡 live session presence: providers push status + context tokens to /sessions#192sdougbrown wants to merge 2 commits into
Conversation
Trailer: sparky/deepseek-flash
| // presencePush writes the current presence state to the broker under the | ||
| // provider's run ID. It sends a complete SessionInfo so the broker's overwrite | ||
| // semantics cleanly reflect the latest values. | ||
| func (p *Provider) presencePush() { |
There was a problem hiding this comment.
presencePush omits ContextTokens, ContextPct, and ContextWindow, which the PR title ("push status + context tokens to /sessions") and the acp provider both include (acp/provider.go:504). If the pi backend exposes usage data, these should be pushed for parity. Note the pi translator (translateAgentEnd, events.go:52) does not extract usage from the backend payload — unlike the acp translator — which suggests the pi backend may not provide it. If so, this is an intentional difference worth a brief comment; if not, add the fields.
There was a problem hiding this comment.
👾 AI Agent
👾 AI Agent
Good catch — this was an intentional difference but undocumented. The pi backend exposes no model-context usage data (translateAgentEnd in internal/runtime/pi/events.go extracts nothing from the backend payload), so there is nothing to push for context_pct/context_tokens/context_window. Added a comment on presencePush explaining that, and noting ACP pushes them because its response payloads carry token counts. Commit a4ed11d. Resolved.
The pi backend exposes no model-context usage data, so presencePush intentionally omits context_pct/context_tokens/context_window. The ACP provider pushes them because its response payloads carry token counts.
|
Addressed 1 comment across 1 file:
Review loop: 1 iteration — comment-only fix, no code change, so no regression surface (full go build + pi provider tests green). |
Adds live session presence so
avenor_peersand/sessionsshow status, context usage, and token counts per run.Why: peer discovery today shows only static metadata (backend/model/dir). A coordinator deciding whether to ask a peer — or a reviewer gauging a sibling's capacity — has no signal about liveness, current status, or how full the context window is.
What changed:
SessionInfogainscontext_pct/context_tokens/context_window(broker.go);/sessionscopies them through,UpdateSessionInfooverwrites cleanly.startingpresence on Start, flipsthinking/idleacross each Prompt boundary, readstotal_tokensfrom the prompt response usage block, and keeps a 5s ticker (sharing the poll context) that refreshes LastSeen/status between turns.avenor_peersrendersN% context (M tokens)per session where reported.Tests:
TestBrokerSessionInfoContextFields,TestPresencePushContextTokens,TestProviderPresencePush. Fullgo build ./...andgo test ./...pass.No change to ask/reply transport or control RPCs — presence only.