Skip to content

feat(tools): add cueapi_get_execution for single-execution lookup#10

Closed
mikemolinet wants to merge 1 commit intocueapi:mainfrom
mikemolinet:add-get-execution-tool
Closed

feat(tools): add cueapi_get_execution for single-execution lookup#10
mikemolinet wants to merge 1 commit intocueapi:mainfrom
mikemolinet:add-get-execution-tool

Conversation

@mikemolinet
Copy link
Copy Markdown
Collaborator

Summary

Companion follow-up to #9 (cueapi_fire_cue). Adds cueapi_get_execution(execution_id) — fetches a single execution by ID, including state, outcome, and any attached evidence.

The natural shape: cueapi_fire_cue returns an execution_id; without get_execution, the only way to look that one row up is paginating cueapi_list_executions. Same complementary shape that cueapi_get_cue already has to cueapi_list_cues.

Changes

File Change
src/tools.ts +11 LoC: tool definition. Reuses the existing executionIdSchema (already defined at line 72 but previously unused — looks like it was sitting there waiting for this)
tests/tools.test.ts +54 LoC: 3 HTTP-contract tests mirroring the existing cueapi_get_cue / cueapi_fire_cue patterns (GET method + path, no body or query, url-encoded execution_id)
README.md Add row to "Tools exposed" table + changelog entry
package.json Bump 0.3.00.4.0 (minor — additive new feature)

Tool shape

cueapi_get_execution({ execution_id: 'exec_...' })

Tests

npm test — all 53 tests pass (was 48; +5 net).

 ✓ tests/pkce.test.ts (8 tests)
 ✓ tests/tools.test.ts (17 tests)
 ✓ tests/oauth-flow.test.ts (13 tests)
 ✓ tests/token-store.test.ts (15 tests)

 Test Files  4 passed (4)
      Tests  53 passed (53)

npm run build — clean.

Notes

  • Endpoint already exists at GET /v1/executions/{id} (executions.py:204) — returns 404 if not found, otherwise the execution dict (same shape as items in list_executions).
  • The "no body or query" test is a deliberate regression guard: if a future refactor reuses the listExecutionsSchema or accidentally pipes args through, the handler could end up sending a body or query params on this single-row endpoint. Test pins the contract.

Adds an MCP tool that wraps GET /v1/executions/{id}, the natural
follow-up to cueapi_fire_cue (which returns an execution_id) when an
agent wants to confirm delivery state without paginating
cueapi_list_executions to find the same row.

Reuses the existing executionIdSchema (already defined but previously
unused). Same complementary shape that cueapi_get_cue is to
cueapi_list_cues.

- src/tools.ts: +11 LoC (tool definition; reuses executionIdSchema)
- tests/tools.test.ts: +54 LoC (3 HTTP-contract tests mirroring the
  existing get_cue / fire_cue patterns: GET method + path, no body
  or query, url-encoded execution_id)
- README.md: add row to "Tools exposed" table + changelog entry
- package.json: bump 0.3.0 → 0.4.0

No backend changes — GET /v1/executions/{id} already exists in the
CueAPI backend (executions.py:204). All 53 tests pass (was 48).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mikemolinet
Copy link
Copy Markdown
Collaborator Author

Superseded by #11, which folds cueapi_get_execution into the larger execution-lifecycle batch (5 tools + small CueAPIClient header-support mod). Closing here.

@mikemolinet mikemolinet closed this May 1, 2026
mikemolinet added a commit that referenced this pull request May 2, 2026
…im-next/heartbeat

Closes the receive-claim-process-complete loop for MCP-host agents that
want to consume worker-transport executions from in-session, alongside
the SEND side that 0.3.0 added with cueapi_fire_cue.

Five new tools:

- cueapi_get_execution(execution_id)
  Wraps GET /v1/executions/{id}. Single-row lookup; the natural
  follow-up to cueapi_fire_cue's returned execution_id.

- cueapi_list_claimable_executions(task_name?, agent?)
  Wraps GET /v1/executions/claimable with the task/agent QUERY PARAMS.
  Filtering MUST be server-side — client-side filter after fetch hits
  the LIMIT 50 starvation bug fixed in the 2026-04-25 prod incident
  (see app/routers/executions.py:122-131).

- cueapi_claim_execution(execution_id, worker_id)
  Wraps POST /v1/executions/{id}/claim. Atomic conditional UPDATE;
  returns 409 if already claimed.

- cueapi_claim_next_execution(worker_id, task_name?)
  Wraps POST /v1/executions/claim. Without task_name → single API
  call. With task_name → internal fan-out (filtered list_claimable →
  pick oldest → claim by ID), since the server's claim endpoint
  doesn't yet accept a task filter. Tiny race window between list
  and claim is bounded by the atomic claim returning 409 → caller
  retries.

- cueapi_execution_heartbeat(execution_id, worker_id)
  Wraps POST /v1/executions/{id}/heartbeat. Sends worker_id via
  the X-Worker-Id REQUEST HEADER (the server's actual transport for
  that field — declared as Header(None), not in the request body).
  worker_id is REQUIRED in the MCP schema even though the server
  permits omission, so misconfigured callers fail at the wrapper
  instead of silently bypassing race protection.

Internal change:

- CueAPIClient.request() gains optional extraHeaders parameter
  (~5 LoC). Defaults are merged first; extraHeaders override them;
  Authorization is set last so a caller can never accidentally
  clobber the bearer token. Used by execution_heartbeat today;
  available for any future endpoint that needs custom headers.

Deferred from this PR:

- report_outcome enum refinement (PRD v3 §"Cowork feedback
  dispositions" #4): server's OutcomeRequest only accepts success:
  bool — there's no outcome_state field, and 'timed_out' from the
  proposed enum isn't worker-reportable (server detects timeout via
  heartbeat lapse; if a worker can call the API, it didn't time
  out). Defer to a follow-up PR where we can resolve the
  timed_out semantics + the breaking-vs-additive call separately.
  Flagged back to PM for re-clarification.

All 65 tests pass (was 48; +17 net): 5 added to surface-coverage
list, 12 new HTTP-contract tests across 5 new describe blocks.
npm run build clean.

Supersedes #10 (cueapi_get_execution as a standalone PR — folded
into this batch).

Co-Authored-By: Claude Opus 4.7 (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