Skip to content

fix(lifecycle): forward TaskID in the Docker create-instance request - #3612

Open
StoyKK wants to merge 1 commit into
kdlbs:mainfrom
StoyKK:fix/docker-create-instance-task-id
Open

fix(lifecycle): forward TaskID in the Docker create-instance request#3612
StoyKK wants to merge 1 commit into
kdlbs:mainfrom
StoyKK:fix/docker-create-instance-task-id

Conversation

@StoyKK

@StoyKK StoyKK commented Sep 11, 2026

Copy link
Copy Markdown

Problem

buildContainerCreateInstanceRequest (apps/backend/internal/agent/runtime/lifecycle/container.go) forwards SessionID but not TaskID to agentctl. The MCP server built inside every freshly launched Local Docker container therefore runs with an empty task binding, and task-bound tools fail for agents running in containers:

  • step_complete_kandevstep_complete_kandev requires a bound task and session
  • set_task_title_kandevset_task_title_kandev requires a bound task

The reconnect path (buildReconnectCreateInstanceRequest) and the standalone/SSH/Sprites/Kubernetes builders already forward both identifiers, so only the fresh Docker launch is affected. This looks like the same defect as #2643 (closed by its author for non-technical reasons).

Reproduction (kandev v0.94.0, Local Docker executor profile, Claude agent)

  1. Workflow step whose prompt ends with a step_complete_kandev call, task launched on a Local Docker profile.
  2. The agent finishes its work and calls step_complete_kandev.
  3. Result: requires a bound task and session; the task stays on its step. The container environment does carry KANDEV_TASK_ID / KANDEV_SESSION_ID, and the agentctl log shows the MCP server enabled with the session id only.

With this change the container-side MCP server binds the task and the step completes normally.

Change

  • container.go: forward config.TaskID in the create-instance request (one line).
  • container_create_instance_test.go: regression test asserting the builder forwards both TaskID and SessionID.

Validation

  • gofmt -l clean on the two files
  • go vet ./internal/agent/runtime/lifecycle/
  • go test ./internal/agent/runtime/lifecycle/ -run TestBuildContainerCreateInstanceRequestForwardsTaskAndSession -count=1 → ok
  • Manually verified on a self-hosted kandev 0.94.0 (Docker executor, Claude ACP agent): with the task id forwarded to agentctl, step_complete_kandev succeeds from inside a fresh container.

No UI change, no public docs impact.

Checklist

  • This PR contains one logical change; unrelated work is split into separate PRs.
  • I have performed a self-review of my code.
  • I have manually tested my changes and they work as expected.
  • My changes have tests that cover the new functionality and edge cases.
  • I checked whether this affects public docs in docs/public/** — no docs change needed (bug fix, no behavior change for users beyond the fix).

🤖 Generated with Claude Code

https://claude.ai/code/session_01FJBBp1qpZ772ibT6QLCwkt

Review in cubic

buildContainerCreateInstanceRequest forwarded SessionID but not TaskID, so the
MCP server built inside every freshly launched Local Docker container ran with
an empty task binding. Task-bound tools then failed for agents in containers:
step_complete_kandev reported "requires a bound task and session" and
set_task_title_kandev "requires a bound task", while the resume/reconnect path
(buildReconnectCreateInstanceRequest) and the other executors already forward
both identifiers.

Reproduced on kandev v0.94.0 with a Local Docker executor profile: a Claude
agent finished its work, called step_complete_kandev and got the error above;
the task stayed on its step. With TaskID forwarded the container-side MCP server
binds the task and the step completes.

Adds a regression test on the container request builder.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FJBBp1qpZ772ibT6QLCwkt
@github-actions github-actions Bot added the small Pull request changes 0-10 application files label Sep 11, 2026
@coderabbitai

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: QUIET

Plan: Advanced

Run ID: dfe74289-b778-433a-937b-125db8c34aa5

📥 Commits

Reviewing files that changed from the base of the PR and between 5506967 and 07885b2.

📒 Files selected for processing (2)
  • apps/backend/internal/agent/runtime/lifecycle/container.go
  • apps/backend/internal/agent/runtime/lifecycle/container_create_instance_test.go

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Summary

Summary by CodeRabbit

  • Bug Fixes

    • Agent instances created inside containers now correctly retain the associated task identifier.
  • Tests

    • Added coverage to verify that task and session information is preserved when creating container-based agent instances.

Walkthrough

The container create-instance request now forwards TaskID from ContainerConfig. A regression test verifies both task and session identifiers.

Changes

Container request forwarding

Layer / File(s) Summary
Request forwarding and regression test
apps/backend/internal/agent/runtime/lifecycle/container.go, apps/backend/internal/agent/runtime/lifecycle/container_create_instance_test.go
buildContainerCreateInstanceRequest forwards config.TaskID. The regression test verifies TaskID and SessionID forwarding.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix

Suggested reviewers: carlosflorencio

Merge Risk: ⚪ Minimal · up to 07885

The container lifecycle request now preserves both task and session bindings, with regression coverage; the change is ready to merge.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the primary change: forwarding TaskID in the Docker create-instance request.
Description check ✅ Passed The description is relevant and mostly complete. It explains the problem, scope, implementation, regression test, validation, and documentation impact. It does not follow the template exactly because …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit hops where task IDs gleam
Session keys follow in a tidy stream
The container carries both with care
Tests watch the values travel there
One small change makes the path complete

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Sep 11, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes fresh Local Docker agent launches by forwarding the task identity alongside the session identity when creating the agentctl instance.

  • Adds ContainerConfig.TaskID to the Docker create-instance request.
  • Adds a focused regression test covering both task and session forwarding.
  • Keeps fresh Docker behavior consistent with standalone and reconnect launch paths.

Confidence Score: 5/5

The PR appears safe to merge; the narrowly scoped fix restores a missing identity field and is covered by an appropriate regression test.

No actionable failures remain: the production launch chain already populates TaskID, the corrected request field is consumed by agentctl as intended, and authorization continues to derive its owner identity from the backend execution record.

Important Files Changed

Filename Overview
apps/backend/internal/agent/runtime/lifecycle/container.go Forwards the existing task ID through the fresh Docker create-instance request, restoring the task binding expected by container-side MCP tools.
apps/backend/internal/agent/runtime/lifecycle/container_create_instance_test.go Adds a direct regression test asserting that the Docker request builder preserves both task and session identifiers.

Reviews (1): Last reviewed commit: "fix(lifecycle): forward TaskID in the Do..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

small Pull request changes 0-10 application files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant