Skip to content

[WIP] feat: configurable worker sticky-cache + event-delivery metric#468

Draft
NiteshDhanpal wants to merge 2 commits into
nextfrom
feat/event-delivery-metric-worker-limits
Draft

[WIP] feat: configurable worker sticky-cache + event-delivery metric#468
NiteshDhanpal wants to merge 2 commits into
nextfrom
feat/event-delivery-metric-worker-limits

Conversation

@NiteshDhanpal

Copy link
Copy Markdown
Contributor

[WIP] — not ready for merge; opening for early visibility.

What

Two independent, load-test-driven changes to the Temporal worker path:

  1. **feat(temporal): expose max_cached_workflowsonAgentexWorker** The sticky workflow-cache size was hardcoded to the temporalio default (1000/worker) and not surfaced. Add a max_cached_workflowsparam (default **1000**, unchanged) and pass it intoWorker(...)`. No behaviour change for existing agents.

  2. **feat(observability): agentex.events.deliverycounter**event/sendis accepted + acked by the ACP server **before** the Temporal signal is attempted, so HTTP success does not mean the event reached a live workflow. New counter tagged withoutcome (delivered/no_live_workflow/error), recorded around send_signalinTemporalTaskService.send_event. no_live_workflow=RPCError/NOT_FOUND(task already completed or idle-timed-out). Best-effort, gated onAGENTEX_EVENT_METRICS; send_event` still raises as before.

Why

A rocket-mock-async-agent load test showed 61% sticky-cache miss / 618k forced evictions → constant workflow replay, and the only "event success" signal was the ACP server's accept log (which hides events that never reached a live workflow). These two changes make the cache tunable and give a true delivery metric.

Verify (Mimir; OTLP → _total, dots→underscores)

sum(rate(agentex_events_delivery_total{outcome="delivered"}[5m]))
  / sum(rate(agentex_events_delivery_total[5m]))            # true delivery rate
sum(rate(agentex_events_delivery_total{outcome="no_live_workflow"}[5m]))  # arrived too late

Note

Paired with agentex-agents PR (raises this agent's max_cached_workflows/activity limits) — this SDK PR should merge first, since max_cached_workflows isn't a valid AgentexWorker kwarg until then.

🤖 Generated with Claude Code

NiteshDhanpal and others added 2 commits July 21, 2026 15:24
Add a max_cached_workflows parameter (default 1000, unchanged) to AgentexWorker and pass it through to the temporalio Worker. The sticky workflow-cache size was previously not configurable, so agents with many concurrent long-lived workflows (e.g. ones that park waiting for events) could not raise it above the SDK default, causing heavy sticky-cache eviction and constant workflow replay under load.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ts.delivery)

event/send is accepted and acked by the ACP server before the Temporal signal is attempted, so an HTTP success does not mean the event reached a live workflow. Add an agentex.events.delivery counter tagged with an outcome label (delivered / no_live_workflow / error) and record it around send_signal in TemporalTaskService.send_event. no_live_workflow (RPCError NOT_FOUND) captures events that arrived after the task completed or idle-timed-out. Recording is best-effort and gated on AGENTEX_EVENT_METRICS; behaviour is otherwise unchanged (send_event still raises).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant