Skip to content

fix: keep flat Context prompt and tools when the transcript has no system message - #38

Merged
simonsmh merged 1 commit into
simonsmh:mainfrom
Eridanus117:fix/flat-context-tools
Oct 20, 2026
Merged

simonsmh merged 1 commit into
simonsmh:mainfrom
Eridanus117:fix/flat-context-tools

Conversation

@Eridanus117

Copy link
Copy Markdown
Contributor

Fixes #37

Problem

resolveRequestContext chose the transcript contract purely by helper presence. omp 18.12.3 exports the full pi-ai transcript toolkit to legacy extensions (oh-my-pi #16313) but still calls stream with a flat Context: systemPrompt and tools are not folded into a leading role: "system" message.

Consequences of taking the transcript path there:

  • getCurrentTools(messages) reads toolsAdded off system messages, finds none, returns [] → every Qoder request went out with tools: [].
  • The model answered with DeepSeek DSML text markup, the host stripped it as a tool-call leak, retried three times and ended with an empty reply.

Verified at the plugin boundary on the same command: ctxTools: 2, resolvedTools: 0 on 18.12.3 vs 2/2 on 18.12.2.

Change

The leading system message is the only proof that the host folded the prompt and tools into the transcript, so require it before replaying:

const initialSystem = getInitialSystemMessage(collapsed.messages);
if (!initialSystem) {
  return {
    messages: context.messages,
    systemText: contentToText(context.systemPrompt || ""),
    tools: context.tools ?? [],
  };
}

The doc comment now names the three contracts: folded transcript (pi ≥0.86), flat context with helpers exported (omp 18.12.x), flat context without helpers (pi ≤0.85).

Tests

  • New: flat Context + full toolkit keeps tools and the prompt (the regression).
  • New: flat Context without tools keeps the prompt and ships no tools.
  • Existing partial-toolkit and folded-transcript cases still pass.
Test Files  21 passed (21)
Tests       313 passed (313)
tsc --noEmit  clean
biome check   clean

End-to-end

Built this branch and installed it over the plugin dir, then ran the stock omp 18.12.3 binary (the version that fails with 0.6.1):

omp 18.12.3 + patched plugin, qoder/DeepSeek-Flash  → reads AGENTS.md, answers correctly
omp 18.12.3 + patched plugin, qoder/DeepSeek-V4-Pro → reads AGENTS.md, answers correctly

Also still correct on omp 18.12.2.

…stem message

Fixes simonsmh#37

omp 18.12.3 exports the full pi-ai transcript toolkit to legacy extensions
yet still calls `stream` with a flat Context, so `systemPrompt` and `tools`
arrive unfolded. `hasTranscript` keyed off helper presence alone, so the
transcript path ran, `getCurrentTools` found no system message to read
`toolsAdded` from, and every request shipped `tools: []` — the model then
answered with DSML text markup and the host dropped the turn as empty.

Take the transcript path only when the collapsed transcript actually has a
leading system message; otherwise keep the flat fields.
@DuckSoft

Copy link
Copy Markdown

Just have ran into the same problem... My diagnose and fix is almost identical to yours. And it did worked. Respect.

@simonsmh
simonsmh merged commit f061e1f into simonsmh:main Oct 20, 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.

fix: tools are dropped when the host exports the transcript toolkit but passes a flat Context (omp 18.12.3)

3 participants