Mantis Reflect
Agent Buildingmantis_reflectMantis Reflect is an Agent Skill for agent building published in the google/mantis repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.
Extracts learnings from execution trajectories at the end of a Mantis loop. Use to parse agent conversations, extract successes, failures, and false assumptions, and append them to learnings.jsonl. Don't use for analyzing source code or writing patches.
How to use this skill
Bring this guide into your coding agent with a prompt tailored to the tool you use.
- Open your project in Codex.
- Copy and paste the prompt below.
- Review files and risks before approving any action.
Inspect the Agent Skill at https://github.com/google/mantis/blob/HEAD/mantis_reflect/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/mantis-reflect, but wait for my approval before writing files or running scripts.
Copying this prompt does not install or run the skill. Review third-party files before use.
Reflector (/mantis_reflect)
System Goal
Execution Trajectory Analyst. Analyzes the sequence of thoughts, tool calls, and observations (the "trajectory" or "conversation") of the other Mantis agents. Extracts valuable insights to prevent future agents from making the same mistakes.
Command Definition
- Command:
/mantis_reflect - Description: Parses execution trajectories from the current loop and
appends structured insights to
learnings.jsonl.
Instructions
Analyze the execution trajectories of the mantis_researcher, mantis_critic,
and mantis_patch agents from the current round to distill what went right and
what went wrong.
Execute the reflection stage as follows:
-
Extract Trajectories (Token Optimization):
- Do not attempt to read the entire, raw
transcript.jsonlorconversation.jsonlfiles natively withread_file, as they can be massive and blow out your context window. - Instead, use your bash/command execution tools to parse and filter the
logs. For example, write a short Python script or use
jq/grepto extract key events: tool error messages, final agent summaries, instances where an agent "gave up", or messages indicating a trust boundary assumption was incorrect.
- Do not attempt to read the entire, raw
-
Synthesize Insights: Review the extracted events. Look for:
- False Assumptions: Did a researcher spend turns trying to exploit a parameter, only to realize it was sanitized upstream in another file?
- Tool Failures: Did the reproducer fail consistently because of a missing library in the sandbox?
- Successful Strategies: Did a patcher successfully fix a bug using a specific idiomatic pattern that should be reused?
-
Append to the Inbox (
learnings.jsonl): For each distinct insight, append a structured JSON object tolearnings.jsonlin the root workspace directory.Reflection Schema Format (
learnings.jsonl){"type": "trajectory_insight", "action": "add | update | remove", "target_entity": "[e.g., auth_module.py or sandbox_env]", "insight": "The researcher assumed input was unsanitized, but it is actually cleansed by the middleware. Do not attempt XSS on this parameter.", "source_stage": "mantis_researcher"}Ensure the file is appended to, not overwritten. When complete, notify the user.