Skip to content

Agent formula delimiter :: breaks when instruction text contains :: or @agent: #1

Description

@cschanhniem

The encodeAgentFormula / decodeAgentFormula functions in src/lib/agents/agentFormula.ts use :: as a delimiter in the header line, but the instruction text is appended unescaped on the line below.

Problem: If the instruction text contains @agent: at the start of a line (after \n), or :: inline, the parser in decodeAgentFormula will misparse it because:

  1. The header detection (startsWith(@agent:)) matches against the full string including the instruction body — so an instruction like @agent: use API key X would be detected as an agent formula header
  2. The decodeAgentFormula only splits on the first \n, but the :: in the header is used for splitting fields — if the instruction (after the newline) happens to start with something that looks like a new header, parsing breaks

Example that triggers this:

@agent: openai::gpt-4o-mini::10
Find funding for Acme Corp :: Series A preferred

This would parse Acme Corp as provider, Series A preferred as model, etc.

Suggested fix: Use a more robust serialization format (e.g., JSON-based encoding, or escape :: in header fields, or use a fixed-number-of-fields parsing approach that stops splitting at the known fields).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions