Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
refactor(llm): constify "Result" structured-output schema name
AkitaOnRails653cdac0bbd9
diff --git a/crates/ai-memory-llm/src/copilot.rs b/crates/ai-memory-llm/src/copilot.rsindex 90d64ac7..492d759d 100644--- a/crates/ai-memory-llm/src/copilot.rs+++ b/crates/ai-memory-llm/src/copilot.rs@@ -17,7 +17,7 @@ use tracing::{debug, info};use crate::auth::CopilotAuth;use crate::auth_file::{load_entry, now_ms, save_entry};use crate::error::{LlmError, LlmResult};-use crate::openai::enforce_strict_object_schemas;+use crate::openai::{STRUCTURED_OUTPUT_SCHEMA_NAME, enforce_strict_object_schemas};use crate::provider::LlmProvider;use crate::text::truncate_with_ellipsis;use crate::types::{ChatRequest, ChatResponse, Role, Usage};@@ -322,7 +322,7 @@ impl LlmProvider for CopilotProvider {enforce_strict_object_schemas(&mut schema);let response_format = CopilotResponseFormat::JsonSchema {json_schema: CopilotJsonSchema {- name: "Result".into(),+ name: STRUCTURED_OUTPUT_SCHEMA_NAME.into(),schema,strict: true,},@@ -826,7 +826,7 @@ mod tests {let request = ChatRequest::user_prompt("json please");let response_format = CopilotResponseFormat::JsonSchema {json_schema: CopilotJsonSchema {- name: "Result".into(),+ name: STRUCTURED_OUTPUT_SCHEMA_NAME.into(),schema: json!({ "type": "object", "properties": {} }),strict: true,},diff --git a/crates/ai-memory-llm/src/openai.rs b/crates/ai-memory-llm/src/openai.rsindex 1794f46e..b27fcdc0 100644--- a/crates/ai-memory-llm/src/openai.rs+++ b/crates/ai-memory-llm/src/openai.rs@@ -16,6 +16,16 @@ use crate::types::{ChatRequest, ChatResponse, Role, Usage};/// Default OpenAI API base.pub const DEFAULT_BASE_URL: &str = "https://api.openai.com";+/// Name embedded in the `json_schema` envelope of every structured-output+/// request OpenAI / openai-compat send. OpenAI's docs use "Result" as the+/// canonical sample name; we standardise on the same literal so the+/// schema-name surface stays one source of truth across the+/// `OpenAiProvider`, the openai-compat strict path (which delegates to+/// this provider), the Copilot provider, and any future fork. Local+/// engines (vLLM / LM Studio) sometimes echo this name in error+/// messages and logs — naming it makes those messages discoverable.+pub(crate) const STRUCTURED_OUTPUT_SCHEMA_NAME: &str = "Result";+/// Build the full URL for an OpenAI-style endpoint. Tolerates the/// conventions found in the wild:/// * `https://api.openai.com` (OpenAI's own docs)@@ -206,7 +216,7 @@ impl LlmProvider for OpenAiProvider {}let response_format = OpenAiResponseFormat::JsonSchema {json_schema: OpenAiJsonSchema {- name: "Result".into(),+ name: STRUCTURED_OUTPUT_SCHEMA_NAME.into(),schema,strict: true,},diff --git a/crates/ai-memory-llm/src/openai_oauth.rs b/crates/ai-memory-llm/src/openai_oauth.rsindex 42d1f8dc..b0a76eae 100644--- a/crates/ai-memory-llm/src/openai_oauth.rs+++ b/crates/ai-memory-llm/src/openai_oauth.rs@@ -17,7 +17,7 @@ use tracing::{debug, info};use crate::auth_file::{load_entry, now_ms, save_entry};use crate::error::{LlmError, LlmResult};-use crate::openai::enforce_strict_object_schemas;+use crate::openai::{STRUCTURED_OUTPUT_SCHEMA_NAME, enforce_strict_object_schemas};use crate::provider::LlmProvider;use crate::text::truncate_with_ellipsis;use crate::types::{ChatRequest, ChatResponse, Role, Usage};@@ -282,7 +282,7 @@ impl LlmProvider for OpenAiOAuthProvider {enforce_strict_object_schemas(&mut schema);let response_format = CodexText {format: CodexTextFormat::JsonSchema {- name: "Result".into(),+ name: STRUCTURED_OUTPUT_SCHEMA_NAME.into(),schema,strict: true,},