output() tool: don't error when no output dir (forked agents)
Forked agents don't have POC_AGENT_OUTPUT_DIR set. The output tool now returns success regardless — forked agents extract output values from the AST via run_with_backend. Subprocess agents still write to disk when the dir is set. Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
33ed54396c
commit
68fbcc351f
1 changed files with 7 additions and 5 deletions
|
|
@ -245,11 +245,13 @@ fn output(args: &serde_json::Value) -> Result<String> {
|
||||||
anyhow::bail!("invalid output key: {}", key);
|
anyhow::bail!("invalid output key: {}", key);
|
||||||
}
|
}
|
||||||
let value = get_str(args, "value")?;
|
let value = get_str(args, "value")?;
|
||||||
let dir = std::env::var("POC_AGENT_OUTPUT_DIR")
|
// Write to disk if output dir is set (subprocess agents),
|
||||||
.map_err(|_| anyhow::anyhow!("no output directory set"))?;
|
// otherwise just return success (forked agents extract from AST)
|
||||||
let path = std::path::Path::new(&dir).join(key);
|
if let Ok(dir) = std::env::var("POC_AGENT_OUTPUT_DIR") {
|
||||||
std::fs::write(&path, value)
|
let path = std::path::Path::new(&dir).join(&key);
|
||||||
|
std::fs::write(&path, &value)
|
||||||
.with_context(|| format!("writing output {}", path.display()))?;
|
.with_context(|| format!("writing output {}", path.display()))?;
|
||||||
|
}
|
||||||
Ok(format!("{}: {}", key, value))
|
Ok(format!("{}: {}", key, value))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue