This project is a starter implementation of agents that reproduces research paper methods using Google ADK. It implements "Agentic Context Engineering" that repeats the cycle of answer generation → introspection → knowledge reflection, aiming to enable local startup and understanding of the overall picture in 5 minutes even for first-time users.
- Execute one cycle of Generation (Generator) → Reflection & Tagging (Reflector) → Playbook Update (Curator)
- Reflect learned insights into
app:playbookto continuously improve answer quality for future interactions - Focus on reproducibility and maintainability with strict schema and small model operations (low cost)
Prerequisites: macOS (or equivalent environment), Python (see .python-version), uv available
# Install dependencies
uv sync
# Launch
uv run main.pyExpected result: Web UI / API (or CLI) starts locally, allowing you to test the flow of one cycle execution.
Text diagram (see links for internal details):
StateInitializer → Generator → Reflector → Curator → (updated state)
sequenceDiagram
participant User
participant ADKFramework as ADK Framework (UI/Orchestrator)
participant StateInitializer
participant Generator
participant Reflector
participant Curator
participant SessionState as Session State (Intermediate Outputs)
participant PlaybookState as Playbook State (app:playbook)
User->>ADKFramework: 1. Send query
ADKFramework->>StateInitializer: 2. Execute (ctx)
StateInitializer->>SessionState: 3. Save user_query, ground_truth=None
StateInitializer->>PlaybookState: 4. Initialize app:playbook (first time only)
StateInitializer-->>ADKFramework: 5. Initialization complete (Event)
ADKFramework-->>User: 6. Display initialization complete (Optional)
ADKFramework->>Generator: 7. Execute (user_query from State, reference PlaybookState)
Generator->>SessionState: 8. Save generator_output
Generator-->>ADKFramework: 9. Generator Output (Event)
ADKFramework-->>User: 10. Display Generator Output
ADKFramework->>Reflector: 11. Execute (generator_output, reference PlaybookState)
Reflector->>SessionState: 12. Save reflector_output
Reflector->>PlaybookState: 13. Update tag statistics
Reflector-->>ADKFramework: 14. Reflector Output (Event)
ADKFramework-->>User: 15. Display Reflector Output
ADKFramework->>Curator: 16. Execute (reflector_output, reference PlaybookState)
Curator->>SessionState: 17. Save curator_output (DeltaBatch)
Curator->>PlaybookState: 18. Apply Delta (Playbook update)
Curator-->>ADKFramework: 19. Curator Output (Event)
ADKFramework-->>User: 20. Display Curator Output (Playbook changes)
- Generator: Generate answers and traces (reasoning, bullet references)
- Reflector: Evaluate output and tag bullets as helpful/harmful/neutral
- Curator: ADD/UPDATE/REMOVE
app:playbookbased on tags and considerations
- StateInitializer (
BaseAgent)- Input:
user_content - Output:
state_delta(user_query,app:playbookinitialization, explicitground_truth=None)
- Input:
- Generator (
Agent)- Model:
Config.generator_model - Output schema:
GeneratorOutput(reasoning: list[str], bullet_ids: list[str], final_answer: str) - State reflection:
session.state['generator_output']
- Model:
- Reflector (
SequentialAgent=reflector_+tag_bullet)- Model:
Config.reflector_model - Output schema:
Reflection(...)andbullet_tags: list[BulletTag] tag_bulletcallsPlaybook.update_bullet_tagto add tag statistics- State reflection:
session.state['reflector_output'], updatedapp:playbook
- Model:
- Curator (
SequentialAgent=curator_+playbook_updater)- Model:
Config.curator_model - Output schema:
DeltaBatch(reasoning, operations: DeltaOperation[]) playbook_updaterappliesPlaybook.apply_delta- State reflection: updated
app:playbook,session.state['curator_output']
- Model:
StateInitializer → Generator → Reflector(reflector_→tag_bullet) → Curator(curator_→playbook_updater)
user_query: Latest user inputapp:playbook: Dictionary representation ofPlaybook(includes section/ID management and tag statistics)generator_output:GeneratorOutputreflector_output:Reflection(includesbullet_tags)curator_output:DeltaBatchground_truth(optional): Expected answer
schemas/playbook.pyBullet(id, section, content, helpful, harmful, neutral, created_at, updated_at)Playbook- Main operations:
add_bullet,update_bullet,remove_bullet,update_bullet_tag,apply_delta - Serialization:
to_dict/from_dict/dumps/loads - For prompting:
as_prompt(),stats()
- Main operations:
schemas/delta.pyDeltaOperation(type: "ADD"|"UPDATE"|"REMOVE", section, content?, bullet_id?)DeltaBatch(reasoning: str, operations: List[DeltaOperation])
main.py: Entry point for local Web UI/APIconfig.py: Configurationpyproject.toml: Dependencies and tool settings (uvcompatible)agents/ace_agent/: ACE agent implementationagent.py: Coordination and state initialization,root_agentdefinitionsub_agents/:generator.py/reflector.py/curator.pyschemas/:playbook.py/delta.py
.env.example: Environment variable templaterefs/: Reference links
- First, run
cp .env.example .envand edit the necessary items. - This repository assumes future use of GCP/Vertex AI Agent Engine. If not configured, startup may fail.
- Even for minimal local experience, the existence of
.envitself is required.
- Dependency resolution fails
- Re-run
uv syncand resolve according to error logs.
- Re-run
- Environment variable error at startup
- Check if
.envwas created and if there are no typos or unset key names.
- Check if
- Python version mismatch
- Refer to
.python-version, match the environment, and retryuv sync.
- Refer to
- When user sends a query,
user_queryis set, and ifapp:playbookis undefined, it's initialized GeneratorgeneratesGeneratorOutput(reasoning/bullet_ids/final_answer)ReflectorgeneratesReflectionand adds tags to bullets viatag_bulletCuratorreturnsDeltaBatchandplaybook_updaterapplies ADD/UPDATE/REMOVE
- Model switching: Change each model name in
config.py - Collection enhancement: Expandable to design that injects
Playbook.as_prompt()into prompts - Automatic organization: Addition of maintenance jobs based on
Playbook.stats()and tag statistics
- ADK dependencies and execution environment are prerequisites
- External API authentication is minimal in this repo (expand with
.env/environment variables as needed)
agents/ace_agent/__init__.pyexposesroot_agent(actual entity isace_iteration)- The system can be integrated into larger applications or used as a standalone service