Skip to content

refactor(agent-core-v2): align request and recovery stage names - #3766

Merged
7Sageer merged 2 commits into
mainfrom
codex/human-naming-structure
Sep 15, 2026
Merged

7Sageer merged 2 commits into
mainfrom
codex/human-naming-structure

Conversation

@7Sageer

@7Sageer 7Sageer commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

Follow-up to #3727. This draft targets codex/rename-human-names so the diff contains only this naming pass; retarget to main after #3727 merges. There is no separate issue for this internal refactor.

Problem

Related functions in the human layer do not consistently reveal their execution order or the objects they process. For example, lowerOpenAIRequest only lowers messages, while planOpenAIRequest already produces request parameters and internalGenerate executes the request. Recovery also exposes the same message override under different names at the proposal and turn layers.

What changed

  • Align recovery proposals with attemptMessageOverride and inline the single-use credential helper so resolve then applyCredential is visible at the upload call site.
  • Rename message lowering to lower*Messages, and pair prepare*Request with execute*Request across all four protocols. Update the preparation option types and existing test references.
  • Distinguish ThinkingContribution from AppliedThinking, and name the trait hook encodeMaxCompletionTokens to separate parameter encoding from the numeric request option.
  • Sync both internal LLM guides, including the lifetime of attempt message overrides.

Request ordering, retry/recovery behavior, and the numeric maxCompletionTokens option are unchanged. encode*Request remains unchanged.

Validation

  • pnpm --filter @moonshot-ai/agent-core-v2 test --maxWorkers=4: 369 files, 6,581 tests passed.
  • pnpm --filter @moonshot-ai/agent-core-v2 typecheck: passed.
  • pnpm lint: passed, 0 errors (2,933 warnings).
  • git diff --check: passed.

Checklist

  • I have read the CONTRIBUTING document.
  • Related work is linked above; this is an internal follow-up to refactor(agent-core-v2): clarify human-layer names #3727.
  • Updated existing test references and verified existing behavior coverage; no behavior was added.
  • Ran gen-changesets; this internal refactor needs no changeset.
  • Updated both internal design guides; no user-facing documentation change is needed.

@changeset-bot

changeset-bot Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 1ffefc1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@7Hanrui

7Hanrui commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

@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: a42109fe65

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

@7Hanrui

7Hanrui commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 47fafdf8c1

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

@7Sageer
7Sageer marked this pull request as ready for review September 15, 2026 12:09
Base automatically changed from codex/rename-human-names to main September 15, 2026 12:09
@7Sageer
7Sageer force-pushed the codex/human-naming-structure branch from 47fafdf to 1ffefc1 Compare September 15, 2026 12:14
@7Sageer
7Sageer merged commit cb9ce61 into main Sep 15, 2026
12 checks passed
@7Sageer
7Sageer deleted the codex/human-naming-structure branch September 15, 2026 12:14
@7Hanrui

7Hanrui commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: cb9ce61eaa

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

7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Oct 5, 2026
Step 6 of the incremental sync to 2.1.1: 29 upstream commits over 370
files. 35 conflicts, concentrated in the TUI layer where the fork's
i18n and pi-tui work sits on top of upstream's message components.

Upstream's changes in this step, all absorbed:
- mermaid code blocks render as terminal diagrams, with a new
  `MermaidRenderMode` preference and a settings entry (MoonshotAI#3851)
- Windows CLI binaries are signed with Azure Artifact Signing (MoonshotAI#3858)
- MCP servers flip to needs-auth when a tool call returns 401, and the
  rejected grant's tokens are invalidated (MoonshotAI#3846)
- the `/desktop` slash command and the `install-app` subcommand (MoonshotAI#3849)
- skill scopes: `SkillScope` joins the catalog types and custom-theme
  becomes tui-only (MoonshotAI#3843)
- Windows 8.3 short paths are watched through their long form (MoonshotAI#3840)
- images upload as file references for Kimi models (MoonshotAI#3784)
- `/usage` and `/status` no longer prompt for login before the first
  message (MoonshotAI#3818)
- completed subagent scopes are evicted behind an LRU cache (MoonshotAI#3778)
- the human layer's request/recovery stage names were aligned (MoonshotAI#3766)
  and its names clarified (MoonshotAI#3727)
- WebBridge's display name became "Kimi Browser Extension" (MoonshotAI#3803)
- diff code blocks are highlighted (MoonshotAI#3802)
- feedback surveys are gated by the resolved kfc model id (MoonshotAI#3795)

Fork behaviour that had to survive:
- the i18n layer: every new upstream string went through `t()` with
  en/zh locale entries (mermaid preference, WebBridge intro, usage
  panel), and the fork's locale JSONs were regenerated
- the pi-tui intent cards and the fork's local Markdown component, kept
  over upstream's pi-tui Markdown import in the message components
- the 128 KiB `max_completion_tokens` cap on the kimi trait
- the fork's media tool folding (read-media-file) and the
  `isMediaUploadAuthError` rename carried through
- the Bun toolchain: flake.nix keeps `impureEnvVars`, the native build
  workflow keeps the Bun steps while taking upstream's Azure signing
  env block, and 05-verify.mjs verifies the checksum before the
  Authenticode branch
- proactiveMediaEviction in the LLM requester, after upstream's warning
  dispatch
- the fork's stricter `isUnauthorizedLikeError` (no message-regex
  fallback) and its OAuth token transaction

This merge also fixes a fork bug the new upstream tests exposed: the
TUI's background-task handler had been switched to the v2 `task.*`
event spelling during the v1→v2 migration, but the SDK's event mapper
translates those back to `background.task.*` before delivery (the
fork's own `notify.ts` already listened for the translated names), so
the handler had been dead code at runtime. The handler and the three
test fixtures that fed it now use `background.task.*` again.

Test expectations re-pinned where the fork's shape differs from
upstream's:
- `assistant-message.test.ts` reads the local Markdown's `sourceText`
  instead of pi-tui's `text`
- the new `markdown.test.ts` calls `setPalette(palette, family)`, the
  fork's two-argument signature
- `choice-picker.test.ts` asserts the mermaid entry, because the fork's
  longer settings list pushes `upgrade` past the 8-row page
- "invalidates stored OAuth tokens when a runtime 401 fails the
  refresh": the fork's token transaction removes the revoked tokens
  while the refresh fails, and the transport closes before the caller
  can flip the entry into needs-auth, so the server ends up failed
  rather than needs-auth. The security-relevant half (stale tokens are
  gone) still holds; the status difference is a known gap to revisit.

Verified: typecheck clean across every package and app; full suite
17594 passed / 81 skipped / 1 todo. The four failures under parallel
load (rpc-events ×2, taskManager ×2) pass in isolation — load-induced
flakes, not regressions.
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.

2 participants