Chapter 12 / 14 min read
Project Map, Test Evidence and the Next Assignment
Project structure, module responsibilities, recorded test outcomes, corrections and the next coding milestone.
Appendix: project map, test evidence and next implementation milestone
A. Project structure
The initial Git commit established the following 12-file project structure:
agentic-ai-lab/
├── .gitignore
├── main.py
├── models/
│ ├── enums.py
│ └── schemas.py
├── orchestration/
│ └── dependency_resolver.py
├── ollama_client.py
├── test_dep_res.py
├── test_schema.py
├── tool_definitions.py
├── tool_executor.py
├── tool_registry.py
└── tools/
└── calculator.py
The initial commit output was:
635a075 Initial commit: Agentic AI learning project
12 files changed, 517 insertions(+)
The project ignores .venv/, __pycache__/ and .pytest_cache/. Virtual environments, generated bytecode and test caches should not be committed as application source.
B. What each module owns
| Module | Responsibility |
|---|---|
main.py | Conversation loop and application entry point |
models/enums.py | Execution and step status values |
models/schemas.py | Pydantic input contracts and TaskStep |
ollama_client.py | Communication with local Ollama |
tool_definitions.py | Model-facing tool descriptions |
tool_registry.py | Tool name to Python function mapping |
tool_executor.py | Validation and controlled tool invocation |
tools/calculator.py | Addition, multiplication and division |
orchestration/dependency_resolver.py | Dependency checks |
test_schema.py | Schema validation experiments |
test_dep_res.py | Dependency behavior tests |
As development progressed, the project added an execution planner and execution-step tests. The 12-file list above describes the initial project snapshot; it does not imply that every later module was present from the beginning.
C. Test evidence from the learning sessions
The following experiments and outputs were produced during development:
Calculator functions
- Addition: 100 + 250 returned 350.
- Multiplication: 10 × 20 returned 200.
- Multiplication with a negative number: −5 × 4 returned −20.
- Division: 100 ÷ 5 returned 20.0.
- Division by zero returned a structured failure.
- Negative division: −100 ÷ 5 returned −20.0.
Pydantic validation
- Valid search query was accepted.
- Integer input was rejected where a strict string was expected.
- An undeclared
adminfield was rejected becauseextra="forbid"was configured. - JSON Schema generation produced the expected properties and required fields.
Ollama tool calling
- A plain string in the message list caused a message-format error.
- A role/content dictionary was accepted.
- The response was inspected as an Ollama
ChatResponse. - A tool-call response was preserved with
model_dump(exclude_none=True). - The tool result was appended as a tool message.
- The next model call generated a natural-language answer.
- The three-operation calculator task produced 2,100.
Execution history and failure handling
- The division-by-zero tool call was recorded as failed.
- The model responded with a clarification rather than inventing a valid result.
- Execution records retained tool name, arguments, status, result and error.
Dependency resolution
The recorded dependency tests returned:
Test 1 - No dependencies: True
Test 2 - Dependency completed: True
Test 3 - Dependency pending: False
Test 4 - Dependency failed: False
Test 5 - Dependency blocked: False
The planner also demonstrated that a cycle eventually produces an “Unable to resolve dependencies” error rather than returning an invalid execution order.
Passing results
Manual result passing was demonstrated:
Step 1: calculate_addition(10, 20) -> 30.0
Step 2: multiply_numbers(30.0, 5) -> 150.0
Results store: {1: 30.0, 2: 150.0}
The resolver function was implemented after this test, but it was not fully integrated into the orchestrator.
D. Important corrections and lessons
- Python type hints are not runtime validation. Use Pydantic at the tool execution boundary.
- Do not confuse JSON Schema with runtime validation. JSON Schema describes the contract to the model; Pydantic validates the actual received data.
- Do not confuse tool definitions with the registry. One describes tools to the LLM; the other maps names to executable functions.
- Preserve the assistant tool-call message. The tool result belongs in the same conversation history.
- Append the final assistant response. Otherwise, later turns lose the final conversational context.
- Use the enum values actually defined. The dependency test initially used
StepStatus.SUCCESS, but the step enum usedCOMPLETED. - A planner's simulated completed set is not actual execution state. Only the executor should mark a real step completed.
- Do not treat a missing dependency as satisfied. Validate the task graph before planning.
- Do not assume model tool calls are independent. Dependencies must be represented and enforced by the application.
- A result reference needs failure semantics. A downstream step must not receive a missing result from a failed prerequisite.
E. The next implementation assignment
The next coding milestone is to integrate the existing pieces into a single dependency-aware calculator executor.
- Validate that every step ID is unique.
- Validate that every dependency ID exists.
- Reject self-dependencies and cycles.
- Find currently ready steps.
- Resolve
source_stepreferences immediately before execution. - Validate resolved arguments using the schema associated with the tool.
- Execute the registered function.
- Record the attempt and update the step status.
- Store successful outputs by step ID.
- Mark dependent steps blocked when a prerequisite fails.
- Repeat until all steps are terminal or a task-level limit is reached.
- Produce a task-level status and business outcome.
Only after this flow is implemented and tested should we call the dependency-aware agent complete.
F. Why this foundation matters for enterprise AI
These building blocks also connect to practical enterprise AI architecture concerns, including the use of Pega as a target environment:
- Pydantic schemas → controlled contracts at integration boundaries.
- Tool registry → explicit capability catalogue.
- Tool executor → governed execution layer.
- Execution records → traceability and audit.
- Dependency planner → orchestration of multi-step business work.
- Result store → data flow between activities.
- Status enums → operational monitoring and recovery.
These are architectural connections, not claims that this learning project is already integrated with Pega or Pega CDH. The purpose is to understand the engineering primitives well enough to apply them in those systems later.
Closing
The project began with a few Python functions and a local model. It progressed into structured tool contracts, controlled dispatch, conversation history, execution records, dependency planning and result passing.
The most valuable outcome is not a claim that an autonomous agent is finished. It is a clear understanding of the responsibilities required to build one—and a concrete next assignment that continues from the code already written.