agents: fix agent file parser to split on first newline
The parser was using split_once("\n\n") which broke when the prompt
started immediately after the JSON header (no blank line). Parse
the first line as JSON, treat the rest as the prompt body.
This commit is contained in:
parent
46db2e7237
commit
a505b9384e
1 changed files with 4 additions and 2 deletions
|
|
@ -50,8 +50,10 @@ fn default_model() -> String { "sonnet".into() }
|
|||
|
||||
/// Parse an agent file: first line is JSON config, rest is the prompt.
|
||||
fn parse_agent_file(content: &str) -> Option<AgentDef> {
|
||||
let (header_str, prompt) = content.split_once("\n\n")?;
|
||||
let header: AgentHeader = serde_json::from_str(header_str.trim()).ok()?;
|
||||
let (first_line, rest) = content.split_once('\n')?;
|
||||
let header: AgentHeader = serde_json::from_str(first_line.trim()).ok()?;
|
||||
// Skip optional blank line between header and prompt body
|
||||
let prompt = rest.strip_prefix('\n').unwrap_or(rest);
|
||||
Some(AgentDef {
|
||||
agent: header.agent,
|
||||
query: header.query,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue