Skip to content

gut(auto-reply): finish thinking-level and model-selection sweep — follow-up to #2335 #2336

@alexey-pelykh

Description

@alexey-pelykh

Context

Follow-up to #2334 / #2335. The core bug (TypeError: modelState.resolveDefaultThinkingLevel is not a function) and the adjacent dead plumbing (modelState threading, createModelSelectionState, resolveDefaultThinkingLevel, XHigh gating, stub file, fabricated test shapes) were swept in #2335. This issue tracks the remaining vestigial thinking-level / model-selection surface that was deliberately deferred from that PR to keep the first pass reviewable.

Per the broader framing: RemoteClaw does NOT control thinking levels or model selection — the CLI runtimes (Claude, Gemini, Codex, OpenCode) own those decisions. Anything in this fork that resolves, gates, or stores thinking-level state is vestigial from upstream OpenClaw.

Scope

1. /think directive end-to-end removal

  • src/auto-reply/reply/directive-handling.parse.ts — delete /think parsing and hasThinkDirective / thinkLevel fields from InlineDirectives
  • src/tui/tui-command-handlers.ts:316 — delete /think help text and slash handler
  • src/gateway/server-methods/chat.ts:976 — delete injectThinking-based /think injection into commandBody
  • src/auto-reply/reply.triggers.trigger-handling.targets-active-session-native-stop.e2e.test.ts — update or delete the e2e test that asserts /think:high gets stripped

2. thinking.ts helper deletion

Once /think parsing is gone, these helpers have no callers:

  • src/auto-reply/thinking.ts — delete normalizeThinkLevel, supportsXHighThinking, formatXHighModelHint, and (if unused) ThinkLevel type
  • src/commands/agent/session.ts:6,155 — remove normalizeThinkLevel import + call on sessionEntry.thinkingLevel
  • src/cron/isolated-agent/run.test-harness.ts:132,134 — remove normalizeThinkLevel / supportsXHighThinking vi.fn mocks

3. Session state thinkingLevel field

  • src/config/sessions/types.ts — delete thinkingLevel from SessionEntry
  • src/gateway/protocol/schema/sessions.ts — delete the gateway schema field
  • src/config/types.agent-defaults.ts:177 — delete the /think comment and any default field
  • Consider backward-compat: existing sessions on disk have thinkingLevel values. Since the field is optional and unread, existing sessions will load fine (extra fields ignored) and save without it.

4. thinkLevel dead passthrough plumbing

These carry thinkLevel through the reply pipeline but nothing consumes it now that XHigh gating and the agent-runner-execution thinkLevel: undefined always-override are the only sinks:

  • src/auto-reply/types.ts:16 — remove ModelSelectedContext.thinkLevel (response-prefix template interpolation)
  • src/auto-reply/reply/queue/types.ts:72 — remove thinkLevel?: unknown from FollowupRun.run
  • src/auto-reply/reply/followup-runner.ts:203 — remove passthrough
  • src/auto-reply/reply/agent-runner-utils.ts:183 — remove from buildEmbeddedRunBaseParams
  • src/auto-reply/reply/agent-runner-execution.ts:231 — remove the always-undefined pass
  • src/auto-reply/reply/get-reply-run.ts:511 — remove thinkLevel: resolvedThinkLevel from followupRun.run
  • src/auto-reply/reply/get-reply.ts (and callers) — remove resolvedThinkLevel plumbing entirely once there is no downstream consumer
  • Test updates: agent-runner.runreplyagent.e2e.test.ts, agent-runner.media-paths.test.ts, commands/agent.test.ts — remove thinkLevel assertions

5. Directive handling model-state internals

handleDirectiveOnly, applyInlineDirectivesFastLane, and their params carry aliasIndex, allowedModelKeys, allowedModelCatalog, resetModelOverride, defaultProvider, defaultModel, initialModelLabel, formatModelSwitchEvent. After #2335 these are always empty/trivial because createModelSelectionState is gone, but the whole directive-handling model-switching path is still wired:

  • src/auto-reply/reply/directive-handling.params.ts — delete the model-state fields from HandleDirectiveOnlyCoreParams
  • src/auto-reply/reply/directive-handling.impl.ts — delete model-switching logic and unused params
  • src/auto-reply/reply/directive-handling.fast-lane.ts — delete the destructures and handleDirectiveOnly call wiring
  • src/auto-reply/reply/get-reply-directives-apply.ts — delete the inline empty-default directiveModelState (introduced as a compat shim in gut(auto-reply): remove dead thinking-level resolution plumbing (#2334) #2335) and the remaining aliasIndex / initialModelLabel / formatModelSwitchEvent threading

6. Docs

  • docs/tools/slash-commands.md — remove /think entries (lines 17, 104, 122)
  • docs/concepts/context.md:139 — remove /think from directive list
  • docs/web/tui.md:94 — remove /think TUI documentation
  • docs/channels/group-messages.md:18,70 — remove /think high examples (use /verbose on instead)

7. Display-layer audit

Native apps and the web UI still reference thinkingLevel in chat views. Needs per-file classification:

  • apps/android/app/src/main/java/org/remoteclaw/app/chat/ChatModels.kt, ChatController.kt
  • apps/android/app/src/main/java/org/remoteclaw/android/chat/ChatController.kt, NodeRuntime.kt
  • apps/shared/RemoteClawKit/Sources/RemoteClawChatUI/ChatViewModel.swift, ChatSessions.swift, ChatComposer.swift
  • apps/shared/RemoteClawKit/Tests/RemoteClawKitTests/ChatViewModelTests.swift
  • ui/src/ui/types.ts, app-render.ts, views/chat.ts, controllers/chat.ts

For each: is the reference pass-through display (rendering what the CLI reports — KEEP) or state driver (mutating/sending — REMOVE)? Do NOT touch native apps without confirming — they compile to distinct binaries with their own release pipelines.

8. Test-layer hardening

  • Delete the global runPreparedReply mock in src/auto-reply/reply/get-reply.test-mocks.ts:39-40 — it currently replaces the real function with vi.fn(async () => undefined), preventing any integration test from exercising the resolveReplyDirectivesrunPreparedReply boundary (this is one of the five shields that hid gut(auto-reply): remove dead thinking-level and model-selection plumbing — TypeError on first-turn messages #2334 from CI)
  • Add a regression test that drives runPreparedReply with resolvedThinkLevel: undefined through the real resolveReplyDirectives chain (no fabricated fixtures)
  • Consider a lint rule that flags as never / as any in test arrangement code — every fabricated shape is a pending production crash

Acceptance Criteria

  • grep -rn "/think\b\|hasThinkDirective\|thinkLevel\|thinkingLevel\|supportsXHighThinking\|normalizeThinkLevel\|formatXHighModelHint" src/ extensions/ docs/ returns only legitimate pass-through display references (if any)
  • pnpm check green
  • pnpm test green
  • LIVE=1 pnpm test:live green on at least one channel smoke test for first-turn message path
  • Native app layers audited — each reference either justified as pass-through or removed
  • Global runPreparedReply mock removed; integration test exercises real chain
  • /think removed from all user-facing docs

Size estimate

~30 files, ~400-600 line deletions, plus per-file judgment on native apps. Larger and more cross-cutting than #2335 — should probably be split into sub-PRs by area (e.g., "directive removal", "thinking.ts helpers", "session state", "docs", "display audit", "test-layer hardening") for reviewability.

Related

Metadata

Metadata

Assignees

Labels

gutRemoving dead upstream subsystems

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions