Some models prepend prose or wrap output in code fences even when instructed to output JSON only. This breaks the orchestration pipeline.
- Orchestrator prompt — strict "JSON only, no markdown, no code fences"
-Q(quiet) flag — reduces extra model preamble- Strict JSON parse — try
json.loads(output)first - JSON extraction fallback — find first
{to last}substring and retry parse - Retry with example — if both fail, send a retry prompt with a full JSON example
--source polybrain— helps with session tracking for debug
def extract_json(text: str) -> str:
"""Salvage JSON from text that may contain prose or markdown."""
text = text.strip()
start = text.find("{")
end = text.rfind("}")
if start != -1 and end != -1 and end > start:
return text[start:end + 1]
return textIf the orchestrator consistently fails to return valid JSON:
- Check the raw output saved to
orchestrator_raw_0.txtin the artifacts directory. - Try a simpler/smaller model — some models handle JSON instructions better than others.
- Run
hermes chat -q 'Return JSON only: {"test": true}' -m your-model -Qto verify the model supports JSON output. - If the orchestrator times out repeatedly (default 120s), check if the model is hanging. Try
hermes chat -q "ping" -m your-model -Q— if it returns in <10s, the model is fine.