Repository navigation
fix: read tools and system prompt from TranscriptContext for pi v0.86.0+ - #108
Conversation
pi v0.86.0 changed the stream input from Context to TranscriptContext, where system prompt and tool declarations are embedded in context.messages instead of top-level properties. Use getCurrentTools/getCurrentSystemPrompt from @earendil-works/pi-ai to extract them, falling back to direct properties for backward compatibility.
|
not fixed yet: |
|
Independently reproduced the same root cause and verified the fix end-to-end (pi 0.87.1, provider 0.7.1):
One concern with this PR as written: it imports the readers in Also note the reporter of #109 says this approach resolves their case, which matches my verification. |
pi 0.86+ passes providers a TranscriptContext whose system prompt and tool declarations live in system messages, so the /alpha/generate request sent no tools and an empty system prompt. Resolve them in index.ts through pi-ai's transcript readers, probed at runtime like registerApiProvider, instead of a named import in core.ts that failed typecheck and extension loading on Oh My Pi. Hosts that still pass the flat fields are unchanged.
|
Shipped in Thanks @domye for finding the TranscriptContext change and @pierreraby for the verification and the host-aware suggestion. I moved the lookup into |
…i >= 0.86 pi 0.86 replaced the flat Context (systemPrompt/tools) with a TranscriptContext where prompt and tool declarations live in role="system" transcript messages. The generate transport builds its own request body and read context.tools directly, so on pi >= 0.86 it declared no tools at all and models wrote tool calls as plain text instead of calling them. Resolve the pi-ai transcript readers at runtime (probed, so pi < 0.86 still loads) and replay the current prompt and tools before building the request. Ported from upstream patlux/pi-commandcode-provider patlux#108.
pi v0.86.0 changed the stream input from Context to TranscriptContext, where system prompt and tool declarations are embedded in context.messages instead of top-level properties. Use getCurrentTools/getCurrentSystemPrompt from @earendil-works/pi-ai to extract them, falling back to direct properties for backward compatibility.