parse_trajectory_block

Function parse_trajectory_block 

Source
pub fn parse_trajectory_block(
    header_name: Option<&str>,
    content: &str,
) -> Result<TrajectoryDef, ConfigError>
Expand description

Parse a Markdown fence trajectory YAML block into a TrajectoryDef, resolving the block name from the header or payload.

The resulting TrajectoryDef is populated from the deserialized YAML payload. The trajectory name is taken from header_name when provided; if header_name is None, the payload name is used. If both are present the function returns an error, and if neither is present it returns an error.

§Errors

Returns ConfigError::YamlParse if the YAML cannot be deserialized, ConfigError::NameConflict if both a header name and a payload name are supplied, or ConfigError::MissingName if no name is provided.

§Examples

use cellstate_pipeline::parse_trajectory_block;

let yaml = r#"
name: my_trajectory
description: "A sample trajectory"
agent_type: "assistant"
token_budget: 1000
memory_refs:
  - mem1
  - mem2
"#;

let def = parse_trajectory_block(None, yaml).expect("parse");
assert_eq!(def.name, "my_trajectory");
assert_eq!(def.agent_type, "assistant");
assert_eq!(def.token_budget, 1000);
assert_eq!(def.memory_refs.len(), 2);