Skip to content

Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors

Rust

refactor(llm): share the balanced JSON object finder inside the crate

Vinícius DS Andradeeac04fe9c44e
diff --git a/crates/ai-memory-llm/src/openai_compat.rs b/crates/ai-memory-llm/src/openai_compat.rs
index 03ed9208..0e9538c7 100644
--- a/crates/ai-memory-llm/src/openai_compat.rs
+++ b/crates/ai-memory-llm/src/openai_compat.rs
@@ -386,7 +386,7 @@ fn is_response_format_rejection(err: &LlmError) -> bool {
/// either truncates the object early or never closes it. This
/// version tracks whether we're inside a `"..."` literal and
/// honours backslash escapes the JSON spec defines.
-fn first_json_object(s: &str) -> Option<&str> {
+pub(crate) fn first_json_object(s: &str) -> Option<&str> {
let start = s.find('{')?;
let mut depth = 0_i32;
let mut in_string = false;