Skip to content

fix(core): reliable L3 persona writes for weak tool-calling models + warn on silent embedding misconfig#112

Open
Lorenzocolucci wants to merge 1 commit into
Tencent:mainfrom
Lorenzocolucci:pr/core-fixes-tencent
Open

fix(core): reliable L3 persona writes for weak tool-calling models + warn on silent embedding misconfig#112
Lorenzocolucci wants to merge 1 commit into
Tencent:mainfrom
Lorenzocolucci:pr/core-fixes-tencent

Conversation

@Lorenzocolucci
Copy link
Copy Markdown

Two small, independent core fixes I hit while running the standalone gateway with an OpenAI-compatible model (Moonshot/Kimi) for extraction.

1. L3 persona is silently dropped with weak tool-calling models

The persona prompt instructed the model to use the write/edit tools (OpenClaw names), but the standalone runner exposes write_to_file/replace_in_file. With a model that has weaker tool-calling, it returned the persona as plain text and called no tool, so the result was discarded and persona.md was never written.

This PR:

  • makes the persona prompt tool-dialect aware (openclaw: write/edit — unchanged default; standalone: write_to_file/replace_in_file);
  • optionally forces the write tool (toolChoice: "required" + stop on write_to_file) so reliable tool-calling is guaranteed when needed;
  • adds a text fallback: if the model still returns the persona as text, it's persisted instead of lost.

The non-forced branch is unchanged; I preserved main's conditional tools spread in the merge.

2. Silent degradation when an embedding provider is misconfigured

When a remote embedding provider is configured but the service fails to initialize (e.g. an empty API key), search silently fell back to keyword-only with no signal. This adds a WARN at startup so the misconfiguration is visible instead of silent.

Testing

Built against current main (build green). Verified the persona path writes persona.md via the tool (fallback count 0) and the WARN fires when the embedding key is missing.

Happy to adjust naming or split these into two PRs if you'd prefer.

…g WARN

L3 persona generation was unreliable on OpenAI-compatible models with weak
tool-calling (e.g. Moonshot/Kimi): the prompt named tools the active runner did
not expose, so the model emitted the persona as plain text and persona.md was
never written — a silently lost generation.

- prompts/persona-generation: parametrize file-tool names by runner dialect
  (standalone write_to_file/replace_in_file vs openclaw write/edit)
- persona-generator: derive dialect from the injected runner; force write via
  tool; fall back to persisting the returned assistant text when the model
  answers with text instead of a tool call
- llm-runner: forceWriteTool (toolChoice:"required" + hasToolCall stop, no
  forced-loop risk); maxRetries 4 for transient DNS blips; log forced tool calls
- store/factory: WARN when a remote embedding provider is configured but the
  EmbeddingService is not initialised (empty apiKey -> silent keyword-only)
- types: add LLMRunParams.forceWriteTool
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