Skip to content

fix(kap-server): keep foreground tasks out of REST polling - #1648

Open
wbxl2000 wants to merge 2 commits into
mainfrom
codex/fix-foreground-subagent-task-projection-stacked
Open

fix(kap-server): keep foreground tasks out of REST polling#1648
wbxl2000 wants to merge 2 commits into
mainfrom
codex/fix-foreground-subagent-task-projection-stacked

Conversation

@wbxl2000

@wbxl2000 wbxl2000 commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

Depends on #1623 and supersedes #1644. Independent from #1645.

Problem

On the v2 backend, foreground Agent runs are present in the internal task service with detached: false. The /api/v1 task list exposed them as incomplete REST task records, while foreground subagent identity and grouping belong to the snapshot and WebSocket roster. A Web task refresh could therefore replace the richer foreground entry with a record that lacked its parent tool call, subagent type, and swarm index.

Filtering those records is only safe once snapshot roster recovery exists, so this PR is stacked directly on fix/kap-server-subagent-roster. #1623 must merge first. #1623 owns refresh recovery, detached task identity, terminal state, monotonic roster lifecycle, and authoritative empty snapshots; this PR only fixes REST polling.

What changed

  • Keep GET /api/v1/sessions/{sid}/tasks background-only by filtering detached: false records, matching the v1 endpoint.
  • Keep the optional Task.run_in_background projection for precise GET-by-id compatibility; a directly requested foreground task reports false.
  • Add a public Web task-poller regression proving a foreground snapshot task keeps its identity while background task data still refreshes from REST.

The branch includes the refreshed #1623 head (d2d8e2f77) through ordinary merge commits. The PR remains exactly the 6 foreground-polling files relative to #1623. No Agent/swarm stop behavior from #1645 is included here.

Verification

  • Base-relative diff: 6 files, 119 insertions, 5 deletions.
  • Current stacked Web integration: 3 files / 126 tests passed; typecheck and production build passed.
  • Current stacked kap-server integration: 4 files / 81 tests passed; typecheck.
  • Current stacked protocol task/snapshot tests: 2 files / 22 tests passed; typecheck.
  • Current Web full suite: 28 files / 516 tests passed.
  • Web check:style: baseline mode, 29 existing findings, no failure.
  • Targeted oxlint: 0 errors (3 pre-existing warnings in the workspace-state test).
  • git diff --check origin/fix/kap-server-subagent-roster...HEAD: passed.
  • Read-only diff audit: no unrelated changes or internal identifiers.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill; the existing foreground-task patch changeset covers this compatibility projection.
  • Ran gen-docs skill; no user guide or changelog update is needed for this internal REST projection.

@changeset-bot

changeset-bot Bot commented Jul 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3b39182

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex review

@pkg-pr-new

pkg-pr-new Bot commented Jul 13, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@c756d1e
npx https://pkg.pr.new/@moonshot-ai/kimi-code@c756d1e

commit: c756d1e

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: bcee4f191f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: c180e0a50b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 15c47375fd

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 029db0819e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: a0fdd99005

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 2ea4f7f2e3

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: c756d1e478

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

wbxl2000 added 2 commits July 15, 2026 14:05
agent-core-v2 registers foreground Agent runs in the task service too
(detached: false, so the LLM can drive them via TaskList/TaskOutput/
TaskStop). The REST projection dropped that distinction and the web
client defaults subagent tasks to background, so foreground subagents
showed up in the dock as entries that never settle and cannot be
stopped. Add the optional run_in_background field to the protocol Task
schema and project info.detached onto it; older servers keep omitting
the field and the client default stays correct for them.
@wbxl2000
wbxl2000 force-pushed the codex/fix-foreground-subagent-task-projection-stacked branch from c756d1e to 3b39182 Compare July 15, 2026 06:06
@wbxl2000
wbxl2000 changed the base branch from fix/kap-server-subagent-roster to main July 15, 2026 06:06
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