Skip to content

feat(agent-core-v2): record compaction droppedCount in wire traces and rename select_tools capability#1707

Merged
sailist merged 3 commits into
MoonshotAI:mainfrom
sailist:fix/agent-core-v2-droppedcount-and-capability-rename
Jul 14, 2026
Merged

feat(agent-core-v2): record compaction droppedCount in wire traces and rename select_tools capability#1707
sailist merged 3 commits into
MoonshotAI:mainfrom
sailist:fix/agent-core-v2-droppedcount-and-capability-rename

Conversation

@sailist

@sailist sailist commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue. This PR closes two parity gaps found in a v1→v2 port audit of packages/agent-core-v2 against packages/agent-core (v1 references: #1448 / commit 65d30177, and #1488 / commit 7bd29ab0).

Problem

Two v1 behaviors were missing or divergent in the v2 engine:

  1. Wire trace droppedCount had no producer. v1's full compaction passes requestLogFields: { kind: 'compaction', droppedCount } on every summarizer request, so each llm.request record in wire.jsonl carries how many history messages had been dropped by overflow / empty-response shrink retries so far. v2 already had the payload field (llmRequestOps) and the reader (llmRequesterService), but the compaction request never set the field, so rebuilding or debugging a compaction retry sequence from wire.jsonl lost that signal.
  2. Capability naming diverged from kosong. v1 renamed the ModelCapability bit select_toolsdynamically_loaded_tools (refactor(kosong): rename select_tools capability to dynamically_loaded_tools #1488), but v2's local llmProtocol fork (capability / catalog / model resolver / toolSelect gate / flag description) still used the old spelling: a config declaring dynamically_loaded_tools takes effect on v1 but is silently ignored on v2, and future ports from kosong would hit a naming mismatch.

What changed

1. Record droppedCount on full-compaction llm.request wire ops (48bd6abbb)

  • fullCompactionService now passes logFields: { droppedCount } on the compaction request source; the existing logFieldsForSourcerecordRequest path writes it into the llm.request payload (kind: 'compaction' tagging was already in place via requestKind: 'full_compaction').
  • Each retry round records the count as of that attempt (0 on the first attempt), matching v1 semantics.
  • Test: the overflow-shrink scenario now asserts the three llm.request records carry (kind, droppedCount) = ('compaction', 0), ('compaction', 2), ('loop', undefined).

2. Rename the select_tools capability to dynamically_loaded_tools (08bd2ed48)

  • Renamed the field in v2's llmProtocol capability and catalog, the model resolver's declared/detected merge, and the toolSelect gate, mirroring v1's kosong change.
  • The declared-capabilities string also becomes dynamically_loaded_tools with no alias kept — no catalogued model or shipped configuration uses the capability, so there is nothing to migrate (same call as v1).
  • Client vocabulary is intentionally untouched: the select_tools tool name and the tool-select flag id stay; the flag description now says "declares dynamically loaded tools", matching v1.
  • Tests and the test harness were updated; tool-name references in tests were kept.

Verification: pnpm typecheck (covers src + test) is clean; 208 tests across the 7 affected test files pass locally.

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, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

sailist added 3 commits July 14, 2026 17:51
…st wire ops

- add per-attempt droppedCount to the llm.request source logFields so
  replays can see how much history each retry round blinded
- cover compaction/loop request events in the full-compaction test
…y_loaded_tools

- rename the ModelCapability bit and catalog field across capability.ts,
  catalog.ts, modelResolverService and the toolSelect gate
- update toolSelect flag description wording to match
- update all affected tests and the test harness capabilityNames helper
@changeset-bot

changeset-bot Bot commented Jul 14, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 30bf4e9

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

@pkg-pr-new

pkg-pr-new Bot commented Jul 14, 2026

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

commit: 30bf4e9

@sailist sailist merged commit 8490c3e into MoonshotAI:main Jul 14, 2026
15 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 30bf4e927e

ℹ️ 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".

Comment on lines +319 to +320
declared.has('dynamically_loaded_tools') ||
detected.dynamically_loaded_tools === true,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the previous capability spelling during migration

For models configured before this rename with capabilities = ['select_tools'] (or KIMI_MODEL_CAPABILITIES=select_tools), this resolver now leaves dynamically_loaded_tools false because it only recognizes the new string; then AgentToolSelectService.enabled() never opens the progressive-disclosure gate even though the model was explicitly configured for it. Either keep declared.has('select_tools') as a compatibility alias or treat this as a breaking config migration rather than a patch.

Useful? React with 👍 / 👎.

Comment on lines +536 to +538
// Per-attempt count of messages dropped by overflow/empty
// shrinks so far; recorded on the llm.request wire op so a
// replay can see how much history each retry round blinded.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Remove the inline implementation comment

packages/agent-core-v2/AGENTS.md says comments in this tree must live only in the top-of-file block and never beside statements. This new inline explanation violates that package rule; move any needed rationale into the file header or let logFields: { droppedCount } stand on its own.

Useful? React with 👍 / 👎.

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