Skip to content

feat(agents): port the Delegate agent as a built-in - #191

Merged
akshaylive merged 3 commits into
mainfrom
akshaya/delegate_agent
Sep 22, 2026
Merged

akshaylive merged 3 commits into
mainfrom
akshaya/delegate_agent

Conversation

@akshaylive

@akshaylive akshaylive commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds delegate as a built-in agent (AgentKind.DELEGATE / DelegateAgentConfig), registered unconditionally like codex/antigravity, wrapping the now-public @uipath/delegate-sdk via a first-party Node stdio host (src/coder_eval/agents/delegate/delegate_host.mjs) since the internal-only @uipath/delegate-stdio host isn't public.
  • Full turn lifecycle, transcript/token accounting, pricing table, docs (docs/agents/DELEGATE.md), example tasks (tasks/delegate/*.yaml), and unit/registration/live test suites — SDK event field shapes are marked # UNVERIFIED pending a real backend run (excluded from golden-master coverage, covered by tests/test_delegate_agent_live.py under -m live).
  • Adds a gated delegate-live-tests CI job (pr-checks.yml), manual-dispatch only, that ROPC-mints a fresh access token (mirroring coder_eval_uipath's refresh-auth.sh flow) and runs tasks/delegate/fizzbuzz_delegate.yaml end to end against a real backend. Skips cleanly until its 6 DELEGATE_ROPC_*/DELEGATE_ORG_ID/DELEGATE_TENANT_ID secrets are configured — they now are.

Test plan

  • make verify passes (5990 passed, 4 pre-existing/unrelated skips, 92.34% coverage)
  • Two independent code reviews of the whole diff, Critical/High/Medium findings fixed
  • Manually dispatch delegate-live-tests once to confirm the ROPC mint + live SDK run actually pass against alpha, then lift the # UNVERIFIED markers / add golden-master coverage if field shapes need correcting

🤖 Generated with Claude Code

@akshaylive akshaylive changed the title feat(agents): port the Delegate agent from coder_eval_uipath as a built-in feat(agents): port the Delegate agent as a built-in Sep 21, 2026
@UiPath UiPath deleted a comment from github-actions Bot Sep 21, 2026
Comment thread src/coder_eval/agents/delegate_agent.py Dismissed
@akshaylive
akshaylive force-pushed the akshaya/delegate_agent branch 7 times, most recently from 8ac6ce5 to 22b592d Compare September 22, 2026 00:12
…lt-in

Adds `delegate` as a built-in agent (AgentKind.DELEGATE / DelegateAgentConfig),
registered unconditionally like codex/antigravity, wrapping the now-public
@uipath/delegate-sdk via a first-party Node stdio host
(src/coder_eval/agents/delegate/delegate_host.mjs) since the internal-only
@uipath/delegate-stdio host isn't public. Full turn lifecycle, transcript/
token accounting, pricing table, docs (docs/agents/DELEGATE.md), example
tasks (tasks/delegate/*.yaml), and unit/registration/live test suites — SDK
event field shapes are marked `# UNVERIFIED` pending a real backend run
(excluded from golden-master coverage, covered by
tests/test_delegate_agent_live.py under -m live).

Also adds a Delegate live-integration CI job (pr-checks.yml) that mints a
fresh access token via the OAuth2 Resource Owner Password Credentials
(ROPC) grant (mirroring coder_eval_uipath's refresh-auth.sh) and runs
tasks/delegate/fizzbuzz_delegate.yaml end to end against a real backend on
every PR, with a presence-check gate so a missing secret skips cleanly
instead of failing a required check. The mint destination is resolved from
a fixed choice-input allowlist rather than a free-form URL, closing a
credential-exfiltration path a free-form workflow_dispatch string would
otherwise open.

Bumps anyio 4.13.0 -> 4.15.1 for two newly-disclosed CVEs
(CVE-2026-63374, CVE-2026-64847), both fixed in 4.14.2+.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@akshaylive
akshaylive force-pushed the akshaya/delegate_agent branch from 22b592d to 4ee1bcc Compare September 22, 2026 00:16
uipreliga

This comment was marked as outdated.

@uipreliga

This comment was marked as outdated.

@uipreliga

This comment was marked as outdated.

@uipreliga
uipreliga self-requested a review September 22, 2026 02:03

@uipreliga uipreliga left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix what oyu agree with and 🚢

akshaylive and others added 2 commits September 21, 2026 21:18
Fixes the review's blockers and most non-blocking findings:

- Crash/timeout turns now fan out ToolEnd(UNRESOLVED)/TurnEnd/AgentEnd to the
  caller's stream_callback (not the EventCollector only), and every mid-turn
  crash path force-kills the host so a retry can never reuse a live host's
  stale queue.
- Spawn the Node host in its own process group and SIGKILL the group on
  force-kill, so the SDK's bundled interop process is reaped instead of
  orphaned.
- _parse_usage warns instead of silently returning None on an unrecognized
  usage shape; added tests for the bucket spellings, model/cost wiring, and
  crash/timeout streaming.
- A transient init-handshake timeout on a mid-run respawn now raises the
  retryable AgentCrashError instead of the non-retryable AgentConfigError.
- Fixed the non-hermetic SDK-resolution test (patched cwd but not
  Path.home()), which passed only for developers who had NOT installed the
  SDK as documented.
- CI: the live-tests job now fails loudly (not silently green) on a missing
  secret outside a fork PR, runs tests/test_delegate_agent_live.py under
  -m live with an "actually ran" assertion, keeps ROPC credentials out of
  curl's argv, derives DELEGATE_ENV from the same dispatch input the token
  mint uses, and the diagnostic script never gates the real run it exists to
  explain.
- Removed dead _TurnState attributes, narrowed an over-broad exception
  suppression, fixed the Node host's process.exit() truncating its own
  `fatal` line under backpressure, added DELEGATE_-namespaced env var
  fallbacks, and closed the delegate/USER_GUIDE/EXTENDING/default.yaml
  roster-doc gaps (with CE047 extended to catch a future one).

Deliberately not touched: the pricing table's hyphenated/dotted twin
divergence (already documented in .claude/notes/agents.md as a known,
pre-existing state, not something to silently "fix" by picking a number),
docker-driver support for the new agent (a real feature addition, not a
review fix), and the ROPC OAuth scope list / lockfile+npm-ci switch (both
touch the CI job that was just brought to green; left as-is to avoid
re-breaking it without a live run to verify against).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
test_delegate_live_token_usage_populated failed live (crashed=False, real
text/tool output, token_usage=None): _parse_usage was never even reached
with a dict, because it was looking in the wrong place entirely.

Confirmed by reading the installed @uipath/delegate-sdk's bundled
dist/index.mjs directly: sendMessage() always resolves to a plain string,
never an object, and no event forwarded through agent.onEvent() ever
carries a `usage` field. The SDK's per-turn token accounting lives only in
its internal store, reachable through DelegateAgent.getLastTurnUsage()
(and the session id through getSessionId()) -- called nowhere in this
agent before now.

- delegate_host.mjs: call both getters right after sendMessage() resolves
  and attach them to the send_ok message (usage, sessionId).
- delegate_agent.py: _handle_send_ok reads them off send_ok's own top
  level instead of a nonexistent nested result dict. _parse_usage now
  reads the getter's real (confirmed, not guessed) shape --
  promptTokens/completionTokens/promptTokensCached/cacheCreationTokens --
  computing uncached_input_tokens = promptTokens - promptTokensCached
  (promptTokens is the OpenAI-style total, promptTokensCached the
  cache-read subset).
- Updated tests to the real send_ok shape and confirmed bucket names.
- .claude/notes/agents.md § Delegate agent records the finding so it
  isn't re-litigated as a guess next time.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@akshaylive
akshaylive merged commit b5d8ba8 into main Sep 22, 2026
16 checks passed
@akshaylive
akshaylive deleted the akshaya/delegate_agent branch September 22, 2026 16:39
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.

3 participants