Skip to content

feat(worker): log the job count of AgentCore jobs - #956

Open
ParidelPooya wants to merge 4 commits into
mainfrom
feat/agentcore-session-w3
Open

ParidelPooya wants to merge 4 commits into
mainfrom
feat/agentcore-session-w3

Conversation

@ParidelPooya

@ParidelPooya ParidelPooya commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Issue #, if available

Closes #949

Part of #954

Twin: aws/aws-durable-execution-sdk-js#1240

Description of changes

What

This change adds the field jobCount to every log line of an AgentCore job.

Why

The agentcore_session epic sends several jobs to one AgentCore session. One session runs in one worker process. So a reader of the logs needs to see which session a job ran in, and how many jobs that process ran before it.

Change

  1. The log lines of a job already carry runtimeSessionId. This change keeps that field.
  2. The worker counts the jobs that it has started. A job counts when the worker accepts it. The request handler raises the count under the lock that registers the callback ID, and passes the value to the job thread. So the count follows the order in which the worker accepts the jobs, as in the JS twin feat(compute-worker): add the job count to AgentCore worker logs aws-durable-execution-sdk-js#1250.
  3. Each log line of the job carries jobCount. Its value is the count that includes this job. So the first job of a process logs jobCount: 1.
  4. A repeated callback ID does not run again. So it does not change the count, and its ignored a repeated job line has no jobCount.
  5. The logger argument of start_agentcore_worker documents the log fields of a job: callbackId, runtimeSessionId and jobCount.

Testing

  1. A new test sends cb-1, cb-1 again, and cb-2, with two session IDs. It checks callbackId, runtimeSessionId and jobCount on both job started lines. It checks that the repeated delivery of cb-1 does not change the count, and that its line has no jobCount.
  2. Mutation checks: the new test fails when the count does not increase, when the count also increases for a repeated delivery, when jobCount is removed from the fields, and when runtimeSessionId is set to None.
  3. tests/agentcore: 35 passed.
  4. The compute-worker package: 507 passed, 1 failed. The failing test is test_create_raises_when_boto3_cannot_build_the_client. It fails the same way on main on my host, because of the host's AWS configuration.
  5. mypy src tests: no issues. hatch fmt --check (hatch 1.16.5): all checks passed.

Design

  • Design note (rule 3): not needed. The change adds one log field and no public API.
  • Simpler options considered (rule 2): a module-level counter. A counter on the job runner is simpler to test, and one process runs one worker.
  • Net change in source lines and in public API members: +20 and -6 source lines (most of them comments and the docstring), +28 test lines. No public API change.

Assumptions

Decisions not covered by the issue or the design note

  • The field name is jobCount, after the issue title. The JS twin should use the same name.
  • A job counts when the worker accepts it. A job whose thread fails to start keeps its count. The count is a log field, so a gap in it after a failed start does no harm, and the worker logs that failure separately.

Checklist

  • Every new branch has a test that fails without it (rule 4)
  • For a bug fix: the first commit adds a test that fails on the current code (rule 5): not a bug fix.
  • Every edited test expectation is listed in the description, with the reason (rule 5): no existing test changed.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Each log line of an AgentCore job now carries jobCount. jobCount is
the number of jobs that this worker process has run, counting this
job. The lines already carry runtimeSessionId. A new test checks
both fields on the "job started" line.

Closes #949
The job count now goes up in the request handler, under the lock that
registers the callback ID. The job thread receives the count as an
argument. So the count follows the order in which the worker accepts
the jobs. A job counts when the worker accepts it.

The test now sends cb-1 twice. The repeated delivery does not change
the count, and its log line has no jobCount.

The logger argument of start_agentcore_worker now documents the log
fields of a job: callbackId, runtimeSessionId and jobCount.
@ParidelPooya
ParidelPooya marked this pull request as ready for review November 23, 2026 23:26
@ParidelPooya
ParidelPooya deployed to ai-pr-review-runtime November 23, 2026 23:26 — with GitHub Actions Active
@ParidelPooya
ParidelPooya deployed to ai-pr-review-runtime November 23, 2026 23:27 — with GitHub Actions Active
@github-actions

This comment has been minimized.

Only the worker's own job lines carry callbackId, runtimeSessionId
and jobCount. Heartbeat, callback and handler lines do not. Say so
in the logger docs instead of implying every job line has them.
@ParidelPooya
ParidelPooya deployed to ai-pr-review-runtime November 24, 2026 01:37 — with GitHub Actions Active
@github-actions

Copy link
Copy Markdown
Contributor

Codex AI review

One approach finding remains at packages/aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/agentcore/worker.py:186. No correctness regression confirmed. Tests were not executed under the read-only review constraints.

Suppressed repeats

  • arf_v1_7ofodubj76v2mcrfdusve443ja — out-of-scope (maintainer verdict)

Reviewed commit 295a304d43ad61a8601ea10874e10baf50d1a162. Workflow run

This branch was successfully deployed

1 active deployment
ai-pr-review-runtime — 295a304d Deployed Nov 24, 2026 by ParidelPooya via ai-pr-review / Codex review / Generate Codex review #3410
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.

[AgentCore session] W3: Add the session ID and job count to worker logs

1 participant