Conversation
refactor: update documentation for getK8sRemoteURLArrayFunc
Bumps [com.fasterxml.jackson.core:jackson-core](https://github.com/FasterXML/jackson-core) from 2.21.0 to 2.21.1. - [Commits](FasterXML/jackson-core@jackson-core-2.21.0...jackson-core-2.21.1) --- updated-dependencies: - dependency-name: com.fasterxml.jackson.core:jackson-core dependency-version: 2.21.1 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com>
…ackson.core-jackson-core-2.21.1 chore(deps): bump com.fasterxml.jackson.core:jackson-core from 2.21.0 to 2.21.1
chore(deps): update commons-logging to version 1.3.6 and jetty-compre…
chore(deps): upgrade Jetty and Okio dependencies to latest versions
…pt wrapper Agent-Logs-Url: https://github.com/OpenAF/openaf/sessions/6dc098b3-008a-41a0-ae8e-0caf57201a9f Co-authored-by: nmaguiar <11761746+nmaguiar@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add exportConversation and importConversation methods to LLM providers
Add cross-provider exportConversation/importConversation to all LLM providers
Mar 27, 2026
nmaguiar
approved these changes
Mar 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Each provider stores conversations in an incompatible internal format — Gemini uses
parts/functionCall/functionResponse, OpenAI usestool_calls/role:"tool", Anthropic uses typed content blocks — making cross-provider conversation transfer lossy or broken for any conversation involving tool calls.Portable Format
A provider-neutral JSON-serialisable format normalised across all providers:
[ { "role": "system"|"user"|"assistant", "content": "string|null" }, { "role": "assistant", "content": null, "toolCalls": [{ "id": "...", "name": "fn", "arguments": { "parsed": "object" } }] }, { "role": "user", "content": null, "toolResults": [{ "id": "...", "name": "fn", "result": "string|object" }] } ]Rules:
roleis always one ofsystem/user/assistant;argumentsis always a parsed object (never a JSON string);toolCallsonly onassistantturns;toolResultsonly onuserturns.Per-Provider Changes
developer→system, batches consecutiverole:"tool"entries into a singletoolResultsuser turn, parsestool_calls[].function.argumentsfrom string to object. Import: reconstructstool_callsarray with synthetic IDs when absent.role:"model"→"assistant", mapsfunctionCallparts→toolCalls,functionResponseparts→toolResults(preserving structured response content). Import: rebuilds nativeparts:[{functionCall}]/parts:[{functionResponse}]entries per tool result.tc.function.argumentsbeing either string or object.id→namemap fromtool_useblocks for name lookup intool_resultentries; maps typed content blocks to portable fields. Import: reconstructstool_use/tool_resultcontent block arrays.API Surface
Both methods are exposed on
ow.ai.gpt.prototypeand forwarded through the$gptwrapper (with odoc documentation). ExistinggetConversation/setConversationbehaviour is unchanged.Original prompt
Summary
Add
exportConversation()andimportConversation(aExport)methods to all LLM provider implementations injs/owrap.ai.js, and expose them as standard methods onow.ai.gptprototype and on the$gpt/$llmwrappers.The goal is to allow a conversation saved from one provider (e.g. OpenAI) to be safely loaded into another provider (e.g. Gemini, Ollama, Anthropic), using a common portable format that preserves all message types including text turns and tool/function call turns.
Background & Problem
Each provider currently stores its
conversationarray in a provider-specific internal format:{ role, content }— but content for tool calls is a complex array withtool_calls,tool_use,tool_result, etc.{ role: "model"|"user", parts: [{text}] }— roles differ ("model"vs"assistant"), and tool calls usefunctionCall/functionResponseparts.{ role, content }— tool calls usetool_callsin message content.getConversation()on Gemini already does partial normalization (converts"model"→"assistant", flattenspartstocontent), but drops non-text parts (tool call/response parts), making round-trip export/import lossy for tool conversations.There is no existing cross-provider export/import facility. Calling
setConversation(providerA.getConversation())on provider B is unsafe because:"model"vs"assistant","developer"vs"system").parts, others usecontent).Requirements
1. Standard Portable Conversation Format
Define a standard portable format as a JSON-serialisable array of message objects. Each entry must carry:
[ { "role": "system" | "user" | "assistant", "content": "<string or null>", "toolCalls": [ // optional – present when the assistant requested tool calls { "id": "<string>", // tool call id (may be empty string for providers that don't track ids) "name": "<string>", // tool/function name "arguments": { ... } // parsed JSON arguments object } ], "toolResults": [ // optional – present on the turn that returns tool results { "id": "<string>", // tool call id (matching a previous toolCalls entry) "name": "<string>", // tool/function name "result": "<string or object>" // tool result content } ] } ]Rules:
rolemust always be one of"system","user","assistant"(never"model","developer","tool").contentis a plain string (ornullwhen the turn is purely a tool call/response).toolCallsis present only onassistantturns that invoked tools.toolResultsis present only onuserturns that carry tool results.2. Per-Provider
exportConversation()MethodAdd
exportConversation()to the internal_robject inside each provider'screate()factory (openai,gemini,ollama,anthropic).Each implementation must convert from the provider's native internal format to the standard portable format above.
OpenAI export logic
{ role, content: string }→ straightforward.{ role: "assistant", tool_calls: [...] }→ emittoolCallsarray;contentmay benull.{ role: "tool", content, tool_call_id }→ emit asrole: "user"withtoolResults."tool"role messages into a singleuser+toolResultsentry where possible."developer"role →"system".Gemini export logic
role: "model"→"assistant".parts: extract text parts intocontent; extractfunctionCallparts intotoolCalls; extractfunctionResponseparts intotoolResults(role becomes"user").role: "system".Ollama export logic
tool_calls→toolCalls;role: "tool"entries →toolResultson auserturn.Anthropic export logic
"text"→contentstring."tool_use"→toolCalls."tool_result"onuserturns →toolResults.3. Per-Provider
importConversation(aExport)MethodAdd
importConversation(aExport)to the internal_robject inside each provider'screate()factory.Each implementation receives the standard portable format and **converts it into the provider's native inte...
This pull request was created from Copilot chat.
💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.