Skip to content

Re-enable compact mode for small local models - #79

Merged
esokullu merged 8 commits into
mainfrom
compact2
May 26, 2026
Merged

Re-enable compact mode for small local models#79
esokullu merged 8 commits into
mainfrom
compact2

Conversation

@esokullu

Copy link
Copy Markdown
Collaborator

Summary

  • Re-enabled compact prompt + reduced tool schema for small local models (2B–8B)
  • Compact mode cuts tool schema from 40+ to 20 tools, reducing decision surface and hallucination
  • Rewrote compact system prompt: shorter, more directive, explicit tool list with clear 4-step pattern
  • Added shadow DOM fallback hint to all system prompts (Ask + Act, Chrome + Firefox)
  • Compact mode is opt-in only (checkbox in provider settings) — no auto-detection
  • Updated README with Compact column in tools table

Changes

  • tools.js — New COMPACT_TOOL_NAMES set (20 tools), rewritten SYSTEM_PROMPT_ACT_COMPACT, updated getToolsForMode() to filter tools when compact is active
  • agent.js — Re-enabled _getActPrompt() compact selection, pass compact flag to getToolsForMode()
  • openai.js — Removed auto-default for Ollama/LM Studio, compact is now explicit opt-in only
  • tools.js (both browsers) — Added shadow DOM fallback hint to all 4 system prompt sections
  • README — Tools table now shows Ask/Act/Compact columns, compact mode explanation

Test plan

  • Enable compact prompt on a local provider in Settings, verify reduced tool schema in verbose/deep verbose log
  • Run a form-fill task with compact mode — verify agent uses set_field/click_ax pattern
  • Verify full prompt still works when compact is unchecked
  • Verify Ollama/LM Studio no longer auto-enable compact (must be manually checked)

🤖 Generated with Claude Code

@vercel

vercel Bot commented May 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
webbrain Ready Ready Preview, Comment May 26, 2026 9:32pm

@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: 4dffc29a80

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// } catch { /* provider not ready yet — use full prompt */ }
try {
const provider = this.providerManager.getActive();
if (provider.useCompactPrompt) return SYSTEM_PROMPT_ACT_COMPACT;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep compact mode opt-in for llama.cpp defaults

This re-enables compact mode based on provider.useCompactPrompt, but the default llama.cpp provider still evaluates that flag to true when useCompactPrompt is unset (src/chrome/src/providers/llamacpp.js), while default configs do not set the key (src/chrome/src/providers/manager.js). The result is that fresh/default llama.cpp setups run compact mode even with an unchecked checkbox, silently reducing the tool schema and changing behavior from the documented opt-in flow.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed — llamacpp.js had useCompactPrompt !== false which defaulted to true when unset. Changed to !!this.config.useCompactPrompt so it's explicit opt-in only, matching openai.js and base.js.

Comment on lines +1089 to +1092
'navigate', 'new_tab', 'wait_for_element',
'fetch_url', 'download_social_media',
'scratchpad_write', 'clarify', 'done',
]);

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 Keep solve_captcha available in compact tool mode

The compact whitelist removes solve_captcha, but the ACT system prompt builder still appends guidance to call solve_captcha whenever CapSolver is enabled (_buildSystemPrompt in agent.js). In compact mode this creates a prompt/schema mismatch where the model is instructed to call a tool that is not exposed, which can stall or fail CAPTCHA-gated automations.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed — added solve_captcha to COMPACT_TOOL_NAMES so it's available when CapSolver is configured.

- llamacpp.js defaulted useCompactPrompt to true when unset — fixed
- solve_captcha added to COMPACT_TOOL_NAMES to match system prompt guidance

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@esokullu

Copy link
Copy Markdown
Collaborator Author

@codex pls check again

@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: 0c71e8fb54

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


const provider = this.providerManager.getActive();
const tools = getToolsForMode(mode, { strictSecretMode: this.strictSecretMode });
const tools = getToolsForMode(mode, { strictSecretMode: this.strictSecretMode, compact: provider.useCompactPrompt });

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Enforce compact allowlist for text-parsed tool calls

Passing compact: provider.useCompactPrompt here only limits the schema sent to providers that return structured tool_calls; when a local model emits text-form calls, _tryParseToolCallsFromText() still accepts any name in AGENT_TOOL_NAMES and executes it, so compact mode can invoke tools outside COMPACT_TOOL_NAMES (e.g., upload_file, download_file). This breaks the new compact-mode contract specifically on the small local models this change targets, and can reintroduce the high-surface behavior the commit is trying to remove.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed — _tryParseToolCallsFromText now takes an allowedNames parameter (defaults to AGENT_TOOL_NAMES). Both call sites pass COMPACT_TOOL_NAMES when the provider has compact mode enabled, so text-parsed tool calls are restricted to the same 20-tool allowlist as the structured schema.

download_files now accepts a single url string or an array. Removes one
tool from the schema, reducing decision surface for the LLM. The old
download_file name is still handled as an alias in agent.js for
backward compatibility with cached conversations.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
_tryParseToolCallsFromText now accepts an allowedNames set. In compact
mode, only COMPACT_TOOL_NAMES are accepted from text-form tool calls,
preventing small local models from invoking tools outside the compact
schema.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@esokullu

Copy link
Copy Markdown
Collaborator Author

@codex pls check again and let me know if it's ready to merge

@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: 84744c5be1

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +2867 to 2869
if (name === 'download_files' || name === 'download_file') {
if (args.url && !args.urls) args.urls = [args.url];
return await downloadFiles(args);

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 filename when routing single-file downloads

This branch now routes both download_file and download_files through downloadFiles(args), but that implementation does not consume args.filename (it only downloads by URL), so single-file calls that provide filename silently ignore the requested save name. This is a functional regression from the previous download_file path (which passed filename through) and conflicts with the updated tool schema that explicitly documents filename support for single-URL downloads.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed — downloadFiles now passes args.filename to chrome.downloads.download when it's a single-URL call. The filename is applied to the first (only) download in the batch.

Comment thread src/chrome/src/agent/agent.js Outdated
// using the structured tool_calls field, try to parse them out.
if ((!result.toolCalls || result.toolCalls.length === 0) && result.content) {
const fallback = this._tryParseToolCallsFromText(result.content);
const fallback = this._tryParseToolCallsFromText(result.content, provider.useCompactPrompt ? COMPACT_TOOL_NAMES : undefined);

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 Parse text fallback against active tool schema, not compact list

When compact mode is enabled, text fallback parsing is hard-restricted to COMPACT_TOOL_NAMES, but ask-mode tool exposure still comes from ASK_ONLY_TOOLS in getToolsForMode(mode==='ask') and includes tools outside the compact set (for example read_pdf, research_url, list_downloads). For local models that emit raw-text tool calls (the exact case this fallback handles), valid ask-mode calls to those tools will be dropped, causing avoidable no-op turns.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed — compact allowlist is now only applied to the text fallback parser in Act mode (mode === 'act' && provider.useCompactPrompt). Ask mode uses the full AGENT_TOOL_NAMES set regardless of compact setting, so read_pdf, research_url, list_downloads etc. remain reachable.

… mode

- downloadFiles now passes args.filename to chrome.downloads for single-URL calls
- Text fallback parser only applies compact allowlist in Act mode, so Ask mode
  tools (read_pdf, research_url, list_downloads) remain reachable for local models

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@esokullu

Copy link
Copy Markdown
Collaborator Author

@codex pls check again and let me know if it's ready to merge

@chatgpt-codex-connector

Copy link
Copy Markdown

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

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@esokullu
esokullu merged commit d730c89 into main May 26, 2026
2 checks passed
@esokullu
esokullu deleted the compact2 branch May 26, 2026 21:38
esokullu added a commit that referenced this pull request Jul 6, 2026
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