mirror of
https://github.com/temporal-community/temporal-ai-agent.git
synced 2026-03-15 22:18:09 +01:00
Model Context Protocol (MCP) support with new use case (#42)
* initial mcp * food ordering with mcp * prompt eng * splitting out goals and updating docs * a diff so I can get tests from codex * a diff so I can get tests from codex * oops, missing files * tests, file formatting * readme and setup updates * setup.md link fixes * readme change * readme change * readme change * stripe food setup script * single agent mode default * prompt engineering for better multi agent performance * performance should be greatly improved * Update goals/finance.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update activities/tool_activities.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * co-pilot PR suggested this change, and now fixed it * stronger wording around json format response * formatting * moved docs to dir * moved image assets under docs * cleanup env example, stripe guidance * cleanup --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
1811e4cf59
commit
5d55a9fe80
74
docs/architecture.md
Normal file
74
docs/architecture.md
Normal file
@@ -0,0 +1,74 @@
|
||||
# Elements
|
||||
These are the main elements of this system. See [architecture decisions](./architecture-decisions.md) for information beind these choices.
|
||||
In this document we will explain each element and their interactions, and then connect them all at the end.
|
||||
<img src="./assets/Architecture_elements.png" width="50%" alt="Architecture Elements">
|
||||
|
||||
## Workflow
|
||||
This is a [Temporal Workflow](https://docs.temporal.io/workflows) - a durable straightforward description of the process to be executed. See [agent_goal_workflow.py](./workflows/agent_goal_workflow.py).
|
||||
Temporal is used to make the process scalable, durable, reliable, secure, and visible.
|
||||
|
||||
### Workflow Responsibilities:
|
||||
- Orchestrates interactive loops:
|
||||
- LLM Loop: Prompts LLM, durably executes LLM, stores responses
|
||||
- Interactive Loop: Elicits responses from input (in our case a human) and validates input responses
|
||||
- Tool Execution Loop: Durably executes Tools
|
||||
- Keeps record of all interactions ([Signals, Queries, Updates](https://docs.temporal.io/develop/python/message-passing))
|
||||
- Handles failures gracefully
|
||||
- Input, LLM and Tool interaction history stored for debugging and analysis
|
||||
|
||||
## Activities
|
||||
These are [Temporal Activities](https://docs.temporal.io/activities). Defined as simple functions, they are auto-retried async/event driven behind the scenes. Activities durably execute Tools and the LLM. See [a sample activity](./activities/tool_activities.py).
|
||||
|
||||
## Tools
|
||||
Tools define the capabilities of the system. They are simple Python functions (could be in any language as Temporal supports multiple languages).
|
||||
They are executed by Temporal Activities. They are “just code” - can connect to any API or system. They also are where the deterministic business logic is: you can validate and retry actions using code you write.
|
||||
Failures are handled gracefully by Temporal.
|
||||
|
||||
Activities + Tools turn the probabalistic input from the user and LLM into deterministic action.
|
||||
|
||||
## Prompts
|
||||
Prompts are where the instructions to the LLM are. Prompts are made up of initial instructions, goal instructions, and tool instructions.
|
||||
See [agent prompts](./prompts/agent_prompt_generators.py) and [goal & tool prompts](./tools/goal_registry.py).
|
||||
|
||||
This is where you can add probabalistic business logic to
|
||||
- to control process flow
|
||||
- describe what to do
|
||||
- give examples of interactions
|
||||
- give instruction and validation for the LLM
|
||||
|
||||
## LLM
|
||||
Probabalistic execution: it will _probably_ do what you tell it to do.
|
||||
Turns the guidance from the prompts (see [agent prompts](./prompts/agent_prompt_generators.py) and [goal prompts](./tools/goal_registry.py)) into
|
||||
You have a choice of providers - see [setup](./setup.md).
|
||||
The LLM:
|
||||
- Drives toward the initial Goal and any subsequent Goals selected by user
|
||||
- Decides what to do based on input, such as:
|
||||
- Validates user input for Tools
|
||||
- Decides when to execute Tools
|
||||
- Decides on next step for Goal
|
||||
- Formats input and interprets output for Tools
|
||||
- is executed by Temporal Activities
|
||||
- API failures and logical failures are handled transparently
|
||||
|
||||
## Interaction
|
||||
Interaction is managed with Temporal Signals and Queries. These are durably stored in Workflow History.
|
||||
History can be used for analysis and debugging. It's all “just code” so it's easy to add new Signals and Queries.
|
||||
Input can be very dynamic, just needs to be serializable.
|
||||
|
||||
The Workflow executes the Interaction Loop: gathering input, validating input, and providing a response:
|
||||
|
||||

|
||||
|
||||
Here's a more detailed example for gathering inputs for Tools:
|
||||
|
||||

|
||||
|
||||
# Architecture Model
|
||||
Now that we have the pieces and what they do, here is a more complete diagram of how the pieces work together:
|
||||
|
||||
|
||||

|
||||
|
||||
|
||||
# Adding features
|
||||
Want to add more Goals and Tools? See [adding goals and tools](./adding-goals-and-tools.md). Have fun!
|
||||
Reference in New Issue
Block a user