mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-04-10 21:12:37 +00:00
Compare commits
8 Commits
release/1.
...
lorenze/im
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
12ceaa2ede | ||
|
|
4a4c99d8a2 | ||
|
|
28a6b855a2 | ||
|
|
d09656664d | ||
|
|
38dcc35645 | ||
|
|
21e9e7e8c9 | ||
|
|
801908356b | ||
|
|
49aa29bb41 |
134
docs/docs.json
134
docs/docs.json
@@ -79,6 +79,101 @@
|
||||
"en/quickstart"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "AI Docs",
|
||||
"pages": [
|
||||
"en/ai/overview",
|
||||
{
|
||||
"group": "Flows",
|
||||
"icon": "arrow-progress",
|
||||
"pages": [
|
||||
"en/ai/flows/index",
|
||||
"en/ai/flows/reference",
|
||||
"en/ai/flows/patterns",
|
||||
"en/ai/flows/troubleshooting",
|
||||
"en/ai/flows/examples"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Agents",
|
||||
"icon": "user",
|
||||
"pages": [
|
||||
"en/ai/agents/index",
|
||||
"en/ai/agents/reference",
|
||||
"en/ai/agents/patterns",
|
||||
"en/ai/agents/troubleshooting",
|
||||
"en/ai/agents/examples"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Crews",
|
||||
"icon": "users",
|
||||
"pages": [
|
||||
"en/ai/crews/index",
|
||||
"en/ai/crews/reference",
|
||||
"en/ai/crews/patterns",
|
||||
"en/ai/crews/troubleshooting",
|
||||
"en/ai/crews/examples"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "LLMs",
|
||||
"icon": "microchip-ai",
|
||||
"pages": [
|
||||
"en/ai/llms/index",
|
||||
"en/ai/llms/reference",
|
||||
"en/ai/llms/patterns",
|
||||
"en/ai/llms/troubleshooting",
|
||||
"en/ai/llms/examples"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Memory",
|
||||
"icon": "database",
|
||||
"pages": [
|
||||
"en/ai/memory/index",
|
||||
"en/ai/memory/reference",
|
||||
"en/ai/memory/patterns",
|
||||
"en/ai/memory/troubleshooting",
|
||||
"en/ai/memory/examples"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Tools",
|
||||
"icon": "wrench",
|
||||
"pages": [
|
||||
"en/ai/tools/index",
|
||||
"en/ai/tools/reference",
|
||||
"en/ai/tools/patterns",
|
||||
"en/ai/tools/troubleshooting",
|
||||
"en/ai/tools/examples"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Core Concepts",
|
||||
"pages": [
|
||||
"en/concepts/agents",
|
||||
"en/concepts/tasks",
|
||||
"en/concepts/crews",
|
||||
"en/concepts/flows",
|
||||
"en/concepts/production-architecture",
|
||||
"en/concepts/knowledge",
|
||||
"en/concepts/llms",
|
||||
"en/concepts/files",
|
||||
"en/concepts/processes",
|
||||
"en/concepts/collaboration",
|
||||
"en/concepts/training",
|
||||
"en/concepts/memory",
|
||||
"en/concepts/reasoning",
|
||||
"en/concepts/planning",
|
||||
"en/concepts/testing",
|
||||
"en/concepts/cli",
|
||||
"en/concepts/tools",
|
||||
"en/concepts/event-listener"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Guides",
|
||||
"pages": [
|
||||
@@ -128,29 +223,6 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Core Concepts",
|
||||
"pages": [
|
||||
"en/concepts/agents",
|
||||
"en/concepts/tasks",
|
||||
"en/concepts/crews",
|
||||
"en/concepts/flows",
|
||||
"en/concepts/production-architecture",
|
||||
"en/concepts/knowledge",
|
||||
"en/concepts/llms",
|
||||
"en/concepts/files",
|
||||
"en/concepts/processes",
|
||||
"en/concepts/collaboration",
|
||||
"en/concepts/training",
|
||||
"en/concepts/memory",
|
||||
"en/concepts/reasoning",
|
||||
"en/concepts/planning",
|
||||
"en/concepts/testing",
|
||||
"en/concepts/cli",
|
||||
"en/concepts/tools",
|
||||
"en/concepts/event-listener"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "MCP Integration",
|
||||
"pages": [
|
||||
@@ -331,6 +403,7 @@
|
||||
"en/learn/human-input-on-execution",
|
||||
"en/learn/human-in-the-loop",
|
||||
"en/learn/human-feedback-in-flows",
|
||||
"en/learn/flowstate-chat-history",
|
||||
"en/learn/kickoff-async",
|
||||
"en/learn/kickoff-for-each",
|
||||
"en/learn/llm-connections",
|
||||
@@ -483,7 +556,6 @@
|
||||
{
|
||||
"group": "Examples",
|
||||
"pages": [
|
||||
"en/examples/example",
|
||||
"en/examples/cookbooks"
|
||||
]
|
||||
}
|
||||
@@ -1482,6 +1554,18 @@
|
||||
"source": "/api-reference",
|
||||
"destination": "/en/api-reference/introduction"
|
||||
},
|
||||
{
|
||||
"source": "/",
|
||||
"destination": "/en/introduction"
|
||||
},
|
||||
{
|
||||
"source": "/en",
|
||||
"destination": "/en/introduction"
|
||||
},
|
||||
{
|
||||
"source": "/en/examples/example",
|
||||
"destination": "/en/examples/cookbooks"
|
||||
},
|
||||
{
|
||||
"source": "/introduction",
|
||||
"destination": "/en/introduction"
|
||||
@@ -1578,4 +1662,4 @@
|
||||
"reddit": "https://www.reddit.com/r/crewAIInc/"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
12
docs/en/ai/agents/examples.mdx
Normal file
12
docs/en/ai/agents/examples.mdx
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
title: "Agents: Examples"
|
||||
description: "Runnable examples for robust agent configuration and execution."
|
||||
icon: "rocket-launch"
|
||||
mode: "wide"
|
||||
---
|
||||
|
||||
## Example links
|
||||
|
||||
- [/en/guides/agents/crafting-effective-agents](/en/guides/agents/crafting-effective-agents)
|
||||
- [/en/learn/customizing-agents](/en/learn/customizing-agents)
|
||||
- [/en/learn/coding-agents](/en/learn/coding-agents)
|
||||
32
docs/en/ai/agents/index.mdx
Normal file
32
docs/en/ai/agents/index.mdx
Normal file
@@ -0,0 +1,32 @@
|
||||
---
|
||||
title: "Agents: Concepts"
|
||||
description: "Agent role contracts, task boundaries, and decision criteria for robust agent behavior."
|
||||
icon: "user"
|
||||
mode: "wide"
|
||||
---
|
||||
|
||||
## When to use
|
||||
|
||||
- You need specialized behavior with explicit role and goal.
|
||||
- You need tool-enabled execution under constraints.
|
||||
|
||||
## When not to use
|
||||
|
||||
- Static transformations are enough without model reasoning.
|
||||
- Task can be solved by deterministic code only.
|
||||
|
||||
## Core decisions
|
||||
|
||||
| Decision | Choose this when |
|
||||
|---|---|
|
||||
| Single agent | Narrow scope, low coordination needs |
|
||||
| Multi-agent crew | Distinct expertise and review loops needed |
|
||||
| Tool-enabled agent | Model needs external actions or data |
|
||||
|
||||
## Canonical links
|
||||
|
||||
- Reference: [/en/ai/agents/reference](/en/ai/agents/reference)
|
||||
- Patterns: [/en/ai/agents/patterns](/en/ai/agents/patterns)
|
||||
- Troubleshooting: [/en/ai/agents/troubleshooting](/en/ai/agents/troubleshooting)
|
||||
- Examples: [/en/ai/agents/examples](/en/ai/agents/examples)
|
||||
- Existing docs: [/en/concepts/agents](/en/concepts/agents)
|
||||
17
docs/en/ai/agents/patterns.mdx
Normal file
17
docs/en/ai/agents/patterns.mdx
Normal file
@@ -0,0 +1,17 @@
|
||||
---
|
||||
title: "Agents: Patterns"
|
||||
description: "Practical agent patterns for role design, tool boundaries, and reliable outputs."
|
||||
icon: "diagram-project"
|
||||
mode: "wide"
|
||||
---
|
||||
|
||||
## Patterns
|
||||
|
||||
1. Role + reviewer pair
|
||||
- One agent drafts, one agent validates.
|
||||
|
||||
2. Tool-bounded agent
|
||||
- Restrict tool list to minimal action set.
|
||||
|
||||
3. Structured output agent
|
||||
- Force JSON or schema output for automation pipelines.
|
||||
22
docs/en/ai/agents/reference.mdx
Normal file
22
docs/en/ai/agents/reference.mdx
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
title: "Agents: Reference"
|
||||
description: "Reference for agent fields, prompt contracts, tool usage, and output constraints."
|
||||
icon: "book"
|
||||
mode: "wide"
|
||||
---
|
||||
|
||||
## Agent contract
|
||||
|
||||
- `role`: stable operating identity
|
||||
- `goal`: measurable completion objective
|
||||
- `backstory`: bounded style and context
|
||||
- `tools`: allowed action surface
|
||||
|
||||
## Output contract
|
||||
|
||||
- Prefer structured outputs for machine workflows.
|
||||
- Define failure behavior for missing tool data.
|
||||
|
||||
## Canonical source
|
||||
|
||||
Primary API details live in [/en/concepts/agents](/en/concepts/agents).
|
||||
12
docs/en/ai/agents/troubleshooting.mdx
Normal file
12
docs/en/ai/agents/troubleshooting.mdx
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
title: "Agents: Troubleshooting"
|
||||
description: "Diagnose and fix common agent reliability and instruction-following failures."
|
||||
icon: "circle-exclamation"
|
||||
mode: "wide"
|
||||
---
|
||||
|
||||
## Common issues
|
||||
|
||||
- Hallucinated tool results: require tool-call evidence in output.
|
||||
- Prompt drift: tighten role and success criteria.
|
||||
- Verbose but low-signal output: enforce concise schema output.
|
||||
12
docs/en/ai/crews/examples.mdx
Normal file
12
docs/en/ai/crews/examples.mdx
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
title: "Crews: Examples"
|
||||
description: "Runnable crew examples for sequential and hierarchical execution."
|
||||
icon: "rocket-launch"
|
||||
mode: "wide"
|
||||
---
|
||||
|
||||
## Example links
|
||||
|
||||
- [/en/guides/crews/first-crew](/en/guides/crews/first-crew)
|
||||
- [/en/learn/sequential-process](/en/learn/sequential-process)
|
||||
- [/en/learn/hierarchical-process](/en/learn/hierarchical-process)
|
||||
26
docs/en/ai/crews/index.mdx
Normal file
26
docs/en/ai/crews/index.mdx
Normal file
@@ -0,0 +1,26 @@
|
||||
---
|
||||
title: "Crews: Concepts"
|
||||
description: "When to use crews, process selection, delegation boundaries, and collaboration strategy."
|
||||
icon: "users"
|
||||
mode: "wide"
|
||||
---
|
||||
|
||||
## When to use
|
||||
|
||||
- You need multiple agents with specialized roles.
|
||||
- You need staged execution and reviewer loops.
|
||||
|
||||
## Process decision table
|
||||
|
||||
| Process | Best for |
|
||||
|---|---|
|
||||
| Sequential | Linear pipelines and deterministic ordering |
|
||||
| Hierarchical | Manager-controlled planning and delegation |
|
||||
|
||||
## Canonical links
|
||||
|
||||
- Reference: [/en/ai/crews/reference](/en/ai/crews/reference)
|
||||
- Patterns: [/en/ai/crews/patterns](/en/ai/crews/patterns)
|
||||
- Troubleshooting: [/en/ai/crews/troubleshooting](/en/ai/crews/troubleshooting)
|
||||
- Examples: [/en/ai/crews/examples](/en/ai/crews/examples)
|
||||
- Existing docs: [/en/concepts/crews](/en/concepts/crews)
|
||||
12
docs/en/ai/crews/patterns.mdx
Normal file
12
docs/en/ai/crews/patterns.mdx
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
title: "Crews: Patterns"
|
||||
description: "Production crew patterns for decomposition, review loops, and hybrid orchestration with Flows."
|
||||
icon: "diagram-project"
|
||||
mode: "wide"
|
||||
---
|
||||
|
||||
## Patterns
|
||||
|
||||
1. Researcher + writer + reviewer
|
||||
2. Manager-directed hierarchical crew
|
||||
3. Flow-orchestrated multi-crew pipeline
|
||||
21
docs/en/ai/crews/reference.mdx
Normal file
21
docs/en/ai/crews/reference.mdx
Normal file
@@ -0,0 +1,21 @@
|
||||
---
|
||||
title: "Crews: Reference"
|
||||
description: "Reference for crew composition, process semantics, task context passing, and execution modes."
|
||||
icon: "book"
|
||||
mode: "wide"
|
||||
---
|
||||
|
||||
## Crew contract
|
||||
|
||||
- `agents`: available executors
|
||||
- `tasks`: work units with expected output
|
||||
- `process`: ordering and delegation semantics
|
||||
|
||||
## Runtime
|
||||
|
||||
- `kickoff()` for synchronous runs
|
||||
- `kickoff_async()` for async execution
|
||||
|
||||
## Canonical source
|
||||
|
||||
Primary API details live in [/en/concepts/crews](/en/concepts/crews).
|
||||
12
docs/en/ai/crews/troubleshooting.mdx
Normal file
12
docs/en/ai/crews/troubleshooting.mdx
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
title: "Crews: Troubleshooting"
|
||||
description: "Common multi-agent coordination failures and practical fixes."
|
||||
icon: "circle-exclamation"
|
||||
mode: "wide"
|
||||
---
|
||||
|
||||
## Common issues
|
||||
|
||||
- Agents overlap on responsibilities: tighten role boundaries.
|
||||
- Output inconsistency: standardize expected outputs per task.
|
||||
- Slow runs: reduce unnecessary handoffs and model size.
|
||||
17
docs/en/ai/flows/examples.mdx
Normal file
17
docs/en/ai/flows/examples.mdx
Normal file
@@ -0,0 +1,17 @@
|
||||
---
|
||||
title: "Flows: Examples"
|
||||
description: "Runnable end-to-end examples for production flow orchestration."
|
||||
icon: "rocket-launch"
|
||||
mode: "wide"
|
||||
---
|
||||
|
||||
## Canonical examples
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Flowstate Chat History" icon="comments" href="/en/learn/flowstate-chat-history">
|
||||
Persistent chat history with summary compaction and memory scope.
|
||||
</Card>
|
||||
<Card title="Flows Concepts Example" icon="arrow-progress" href="/en/concepts/flows">
|
||||
Full API and feature-oriented flow examples, including routers and persistence.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
39
docs/en/ai/flows/index.mdx
Normal file
39
docs/en/ai/flows/index.mdx
Normal file
@@ -0,0 +1,39 @@
|
||||
---
|
||||
title: "Flows: Concepts"
|
||||
description: "When to use Flows, when not to use them, and key design constraints for production orchestration."
|
||||
icon: "arrow-progress"
|
||||
mode: "wide"
|
||||
---
|
||||
|
||||
## When to use
|
||||
|
||||
- You need deterministic orchestration, branching, and resumable execution.
|
||||
- You need explicit state transitions across steps.
|
||||
- You need persistence, routing, and event-driven control.
|
||||
|
||||
## When not to use
|
||||
|
||||
- A single prompt/response interaction is enough.
|
||||
- You only need one agent call without orchestration logic.
|
||||
|
||||
## Core decisions
|
||||
|
||||
| Decision | Choose this when |
|
||||
|---|---|
|
||||
| Unstructured state | Fast prototyping, highly dynamic fields |
|
||||
| Structured state | Stable contracts, team development, type safety |
|
||||
| `@persist()` | Long-running workflows and recovery requirements |
|
||||
| Router labels | Deterministic branch handling |
|
||||
|
||||
## Canonical links
|
||||
|
||||
- Reference: [/en/ai/flows/reference](/en/ai/flows/reference)
|
||||
- Patterns: [/en/ai/flows/patterns](/en/ai/flows/patterns)
|
||||
- Troubleshooting: [/en/ai/flows/troubleshooting](/en/ai/flows/troubleshooting)
|
||||
- Examples: [/en/ai/flows/examples](/en/ai/flows/examples)
|
||||
|
||||
## Existing docs
|
||||
|
||||
- [/en/concepts/flows](/en/concepts/flows)
|
||||
- [/en/guides/flows/mastering-flow-state](/en/guides/flows/mastering-flow-state)
|
||||
- [/en/learn/flowstate-chat-history](/en/learn/flowstate-chat-history)
|
||||
29
docs/en/ai/flows/patterns.mdx
Normal file
29
docs/en/ai/flows/patterns.mdx
Normal file
@@ -0,0 +1,29 @@
|
||||
---
|
||||
title: "Flows: Patterns"
|
||||
description: "Production flow patterns: triage routing, flowstate chat history, and human-in-the-loop checkpoints."
|
||||
icon: "diagram-project"
|
||||
mode: "wide"
|
||||
---
|
||||
|
||||
## Recommended patterns
|
||||
|
||||
1. Triage router flow
|
||||
- Inputs: normalized request payload
|
||||
- Output: deterministic route label + action
|
||||
- Reference: [/en/concepts/flows](/en/concepts/flows)
|
||||
|
||||
2. Flowstate chat history
|
||||
- Inputs: `session_id`, `last_user_message`
|
||||
- Output: assistant reply + compact context state
|
||||
- Reference: [/en/learn/flowstate-chat-history](/en/learn/flowstate-chat-history)
|
||||
|
||||
3. Human feedback gates
|
||||
- Inputs: generated artifact + reviewer feedback
|
||||
- Output: approved/rejected/revision path
|
||||
- Reference: [/en/learn/human-feedback-in-flows](/en/learn/human-feedback-in-flows)
|
||||
|
||||
## Pattern requirements
|
||||
|
||||
- declare explicit input schema
|
||||
- define expected output shape
|
||||
- list failure modes and retries
|
||||
34
docs/en/ai/flows/reference.mdx
Normal file
34
docs/en/ai/flows/reference.mdx
Normal file
@@ -0,0 +1,34 @@
|
||||
---
|
||||
title: "Flows: Reference"
|
||||
description: "API-oriented reference for Flow decorators, lifecycle semantics, state, routing, and persistence."
|
||||
icon: "book"
|
||||
mode: "wide"
|
||||
---
|
||||
|
||||
## Decorators
|
||||
|
||||
- `@start()` entrypoint, optional conditional trigger
|
||||
- `@listen(...)` downstream method subscription
|
||||
- `@router(...)` label-based deterministic routing
|
||||
- `@persist()` automatic state persistence checkpoints
|
||||
|
||||
## Runtime contracts
|
||||
|
||||
- `kickoff(inputs=...)` initializes or updates run inputs.
|
||||
- final output is the value from the last completed method.
|
||||
- `self.state` always has an auto-generated `id`.
|
||||
|
||||
## State contracts
|
||||
|
||||
- Use typed state for durable workflows.
|
||||
- Keep control fields explicit (`route`, `status`, `retry_count`).
|
||||
- Avoid storing unbounded raw transcripts in state.
|
||||
|
||||
## Resume and recovery
|
||||
|
||||
- Use persistence for recoverable runs.
|
||||
- Keep idempotent step logic for safe retries.
|
||||
|
||||
## Canonical source
|
||||
|
||||
Primary API details live in [/en/concepts/flows](/en/concepts/flows).
|
||||
28
docs/en/ai/flows/troubleshooting.mdx
Normal file
28
docs/en/ai/flows/troubleshooting.mdx
Normal file
@@ -0,0 +1,28 @@
|
||||
---
|
||||
title: "Flows: Troubleshooting"
|
||||
description: "Common flow failures, causes, and fixes for state, routing, persistence, and resumption."
|
||||
icon: "circle-exclamation"
|
||||
mode: "wide"
|
||||
---
|
||||
|
||||
## Common issues
|
||||
|
||||
### Branch did not trigger
|
||||
|
||||
- Cause: router label mismatch.
|
||||
- Fix: align returned label with `@listen("label")` exactly.
|
||||
|
||||
### State fields missing
|
||||
|
||||
- Cause: untyped dynamic writes or missing inputs.
|
||||
- Fix: switch to typed state and validate required fields at `@start()`.
|
||||
|
||||
### Context window blow-up
|
||||
|
||||
- Cause: raw message accumulation.
|
||||
- Fix: use sliding window + summary compaction pattern.
|
||||
|
||||
### Resume behavior inconsistent
|
||||
|
||||
- Cause: non-idempotent side effects in retried steps.
|
||||
- Fix: make side-effecting calls idempotent and record execution markers in state.
|
||||
12
docs/en/ai/llms/examples.mdx
Normal file
12
docs/en/ai/llms/examples.mdx
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
title: "LLMs: Examples"
|
||||
description: "Concrete examples for model setup, routing, and output-control patterns."
|
||||
icon: "rocket-launch"
|
||||
mode: "wide"
|
||||
---
|
||||
|
||||
## Example links
|
||||
|
||||
- [/en/concepts/llms](/en/concepts/llms)
|
||||
- [/en/learn/llm-connections](/en/learn/llm-connections)
|
||||
- [/en/learn/custom-llm](/en/learn/custom-llm)
|
||||
27
docs/en/ai/llms/index.mdx
Normal file
27
docs/en/ai/llms/index.mdx
Normal file
@@ -0,0 +1,27 @@
|
||||
---
|
||||
title: "LLMs: Concepts"
|
||||
description: "Model selection strategy, cost-quality tradeoffs, and reliability posture for CrewAI systems."
|
||||
icon: "microchip-ai"
|
||||
mode: "wide"
|
||||
---
|
||||
|
||||
## When to use advanced LLM configuration
|
||||
|
||||
- You need predictable quality, latency, and cost control.
|
||||
- You need model routing by task type.
|
||||
|
||||
## Core decisions
|
||||
|
||||
| Decision | Choose this when |
|
||||
|---|---|
|
||||
| Single model | Small systems with uniform task profile |
|
||||
| Routed models | Mixed workloads with different quality/cost needs |
|
||||
| Structured output | Automation pipelines and strict parsing needs |
|
||||
|
||||
## Canonical links
|
||||
|
||||
- Reference: [/en/ai/llms/reference](/en/ai/llms/reference)
|
||||
- Patterns: [/en/ai/llms/patterns](/en/ai/llms/patterns)
|
||||
- Troubleshooting: [/en/ai/llms/troubleshooting](/en/ai/llms/troubleshooting)
|
||||
- Examples: [/en/ai/llms/examples](/en/ai/llms/examples)
|
||||
- Existing docs: [/en/concepts/llms](/en/concepts/llms)
|
||||
17
docs/en/ai/llms/patterns.mdx
Normal file
17
docs/en/ai/llms/patterns.mdx
Normal file
@@ -0,0 +1,17 @@
|
||||
---
|
||||
title: "LLMs: Patterns"
|
||||
description: "Model routing, reliability defaults, and structured outputs for production AI workflows."
|
||||
icon: "diagram-project"
|
||||
mode: "wide"
|
||||
---
|
||||
|
||||
## Patterns
|
||||
|
||||
1. Role-based model routing
|
||||
2. Reliability defaults (`timeout`, `max_retries`, low temperature)
|
||||
3. JSON-first outputs for machine consumption
|
||||
4. Responses API for multi-turn reasoning flows
|
||||
|
||||
## Reference
|
||||
|
||||
- [/en/concepts/llms#production-llm-patterns](/en/concepts/llms#production-llm-patterns)
|
||||
25
docs/en/ai/llms/reference.mdx
Normal file
25
docs/en/ai/llms/reference.mdx
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
title: "LLMs: Reference"
|
||||
description: "Provider-agnostic LLM configuration reference for CrewAI projects."
|
||||
icon: "book"
|
||||
mode: "wide"
|
||||
---
|
||||
|
||||
## Common parameters
|
||||
|
||||
- `model`
|
||||
- `temperature`
|
||||
- `max_tokens`
|
||||
- `timeout`
|
||||
- `max_retries`
|
||||
- `response_format`
|
||||
|
||||
## Contract guidance
|
||||
|
||||
- Set low temperature for extraction/classification.
|
||||
- Use structured outputs for downstream automation.
|
||||
- Set explicit timeout and retry policy for production.
|
||||
|
||||
## Canonical source
|
||||
|
||||
Primary API details live in [/en/concepts/llms](/en/concepts/llms).
|
||||
12
docs/en/ai/llms/troubleshooting.mdx
Normal file
12
docs/en/ai/llms/troubleshooting.mdx
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
title: "LLMs: Troubleshooting"
|
||||
description: "Fix common model behavior failures: drift, latency spikes, malformed output, and cost overruns."
|
||||
icon: "circle-exclamation"
|
||||
mode: "wide"
|
||||
---
|
||||
|
||||
## Common issues
|
||||
|
||||
- Malformed JSON: enforce `response_format` and validate at boundary.
|
||||
- Latency spikes: route heavy tasks to smaller models when acceptable.
|
||||
- Cost growth: add budget-aware model routing and truncation rules.
|
||||
11
docs/en/ai/memory/examples.mdx
Normal file
11
docs/en/ai/memory/examples.mdx
Normal file
@@ -0,0 +1,11 @@
|
||||
---
|
||||
title: "Memory: Examples"
|
||||
description: "Runnable examples for scoped storage and semantic retrieval in CrewAI."
|
||||
icon: "rocket-launch"
|
||||
mode: "wide"
|
||||
---
|
||||
|
||||
## Example links
|
||||
|
||||
- [/en/concepts/memory](/en/concepts/memory)
|
||||
- [/en/learn/flowstate-chat-history](/en/learn/flowstate-chat-history)
|
||||
24
docs/en/ai/memory/index.mdx
Normal file
24
docs/en/ai/memory/index.mdx
Normal file
@@ -0,0 +1,24 @@
|
||||
---
|
||||
title: "Memory: Concepts"
|
||||
description: "Designing recall systems with scope boundaries and state-vs-memory separation."
|
||||
icon: "database"
|
||||
mode: "wide"
|
||||
---
|
||||
|
||||
## When to use memory
|
||||
|
||||
- You need semantic recall across runs.
|
||||
- You need long-term context outside immediate flow state.
|
||||
|
||||
## When to use state instead
|
||||
|
||||
- Data is only needed for current control flow.
|
||||
- Data must remain deterministic and explicit per step.
|
||||
|
||||
## Canonical links
|
||||
|
||||
- Reference: [/en/ai/memory/reference](/en/ai/memory/reference)
|
||||
- Patterns: [/en/ai/memory/patterns](/en/ai/memory/patterns)
|
||||
- Troubleshooting: [/en/ai/memory/troubleshooting](/en/ai/memory/troubleshooting)
|
||||
- Examples: [/en/ai/memory/examples](/en/ai/memory/examples)
|
||||
- Existing docs: [/en/concepts/memory](/en/concepts/memory)
|
||||
17
docs/en/ai/memory/patterns.mdx
Normal file
17
docs/en/ai/memory/patterns.mdx
Normal file
@@ -0,0 +1,17 @@
|
||||
---
|
||||
title: "Memory: Patterns"
|
||||
description: "Practical memory patterns for session recall, scoped retrieval, and hybrid flow-state designs."
|
||||
icon: "diagram-project"
|
||||
mode: "wide"
|
||||
---
|
||||
|
||||
## Patterns
|
||||
|
||||
1. Session-scoped recall (`/chat/{session_id}`)
|
||||
2. Project-scoped knowledge (`/project/{project_id}`)
|
||||
3. Hybrid pattern: flow state for control, memory for long-tail context
|
||||
|
||||
## Reference
|
||||
|
||||
- [/en/learn/flowstate-chat-history](/en/learn/flowstate-chat-history)
|
||||
- [/en/guides/flows/mastering-flow-state](/en/guides/flows/mastering-flow-state)
|
||||
23
docs/en/ai/memory/reference.mdx
Normal file
23
docs/en/ai/memory/reference.mdx
Normal file
@@ -0,0 +1,23 @@
|
||||
---
|
||||
title: "Memory: Reference"
|
||||
description: "Reference for remember/recall contracts, scopes, and retrieval tuning."
|
||||
icon: "book"
|
||||
mode: "wide"
|
||||
---
|
||||
|
||||
## API surface
|
||||
|
||||
- `remember(content, scope=...)`
|
||||
- `recall(query, limit=...)`
|
||||
- `extract_memories(text)`
|
||||
- `scope(path)` and `subscope(name)`
|
||||
|
||||
## Scope rules
|
||||
|
||||
- use `/{entity_type}/{identifier}` paths
|
||||
- keep hierarchy shallow
|
||||
- isolate sessions by stable identifiers
|
||||
|
||||
## Canonical source
|
||||
|
||||
Primary API details live in [/en/concepts/memory](/en/concepts/memory).
|
||||
12
docs/en/ai/memory/troubleshooting.mdx
Normal file
12
docs/en/ai/memory/troubleshooting.mdx
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
title: "Memory: Troubleshooting"
|
||||
description: "Diagnose poor recall quality, scope leakage, and stale memory retrieval."
|
||||
icon: "circle-exclamation"
|
||||
mode: "wide"
|
||||
---
|
||||
|
||||
## Common issues
|
||||
|
||||
- Irrelevant recall: tighten scopes and query wording.
|
||||
- Missing recall: check scope path and recency weighting.
|
||||
- Scope leakage: avoid shared broad scopes for unrelated workflows.
|
||||
54
docs/en/ai/overview.mdx
Normal file
54
docs/en/ai/overview.mdx
Normal file
@@ -0,0 +1,54 @@
|
||||
---
|
||||
title: "AI-First Documentation"
|
||||
description: "Canonical, agent-optimized documentation map for Flows, Agents, Crews, LLMs, Memory, and Tools."
|
||||
icon: "sitemap"
|
||||
mode: "wide"
|
||||
---
|
||||
|
||||
## Purpose
|
||||
|
||||
This section is the canonical map for AI agents and developers.
|
||||
|
||||
Use it when you need:
|
||||
- one source of truth per domain
|
||||
- predictable page structure
|
||||
- runnable patterns with explicit inputs and outputs
|
||||
|
||||
## Domain Packs
|
||||
|
||||
<CardGroup cols={3}>
|
||||
<Card title="Flows" icon="arrow-progress" href="/en/ai/flows/index">
|
||||
State, routing, persistence, resume, and orchestration lifecycle.
|
||||
</Card>
|
||||
<Card title="Agents" icon="user" href="/en/ai/agents/index">
|
||||
Agent contracts, tool boundaries, prompt roles, and output discipline.
|
||||
</Card>
|
||||
<Card title="Crews" icon="users" href="/en/ai/crews/index">
|
||||
Multi-agent execution, process choice, delegation, and coordination.
|
||||
</Card>
|
||||
<Card title="LLMs" icon="microchip-ai" href="/en/ai/llms/index">
|
||||
Model configuration contracts, routing, reliability defaults, and providers.
|
||||
</Card>
|
||||
<Card title="Memory" icon="database" href="/en/ai/memory/index">
|
||||
Retrieval semantics, scope design, and state-vs-memory architecture.
|
||||
</Card>
|
||||
<Card title="Tools" icon="wrench" href="/en/ai/tools/index">
|
||||
Tool safety, schema contracts, retries, and integration patterns.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
## Writing Contract
|
||||
|
||||
Every domain follows the same structure:
|
||||
1. Concepts (`index`)
|
||||
2. Reference (`reference`)
|
||||
3. Patterns (`patterns`)
|
||||
4. Troubleshooting (`troubleshooting`)
|
||||
5. Examples (`examples`)
|
||||
|
||||
## Deprecation Policy
|
||||
|
||||
When a page is replaced:
|
||||
- keep a redirect for the old URL
|
||||
- keep one canonical destination
|
||||
- avoid duplicated conceptual prose
|
||||
12
docs/en/ai/tools/examples.mdx
Normal file
12
docs/en/ai/tools/examples.mdx
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
title: "Tools: Examples"
|
||||
description: "Practical examples for tool-driven agents and crews."
|
||||
icon: "rocket-launch"
|
||||
mode: "wide"
|
||||
---
|
||||
|
||||
## Example links
|
||||
|
||||
- [/en/tools/overview](/en/tools/overview)
|
||||
- [/en/learn/create-custom-tools](/en/learn/create-custom-tools)
|
||||
- [/en/learn/tool-hooks](/en/learn/tool-hooks)
|
||||
25
docs/en/ai/tools/index.mdx
Normal file
25
docs/en/ai/tools/index.mdx
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
title: "Tools: Concepts"
|
||||
description: "Tool selection strategy, safety boundaries, and reliability rules for agentic execution."
|
||||
icon: "wrench"
|
||||
mode: "wide"
|
||||
---
|
||||
|
||||
## When to use tools
|
||||
|
||||
- Agents need external data or side effects.
|
||||
- Deterministic systems must be integrated into agent workflows.
|
||||
|
||||
## Tool safety rules
|
||||
|
||||
- define clear input schemas
|
||||
- validate outputs before downstream use
|
||||
- isolate privileged tools behind policy checks
|
||||
|
||||
## Canonical links
|
||||
|
||||
- Reference: [/en/ai/tools/reference](/en/ai/tools/reference)
|
||||
- Patterns: [/en/ai/tools/patterns](/en/ai/tools/patterns)
|
||||
- Troubleshooting: [/en/ai/tools/troubleshooting](/en/ai/tools/troubleshooting)
|
||||
- Examples: [/en/ai/tools/examples](/en/ai/tools/examples)
|
||||
- Existing docs: [/en/concepts/tools](/en/concepts/tools)
|
||||
12
docs/en/ai/tools/patterns.mdx
Normal file
12
docs/en/ai/tools/patterns.mdx
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
title: "Tools: Patterns"
|
||||
description: "Tool execution patterns for retrieval, action safety, and response grounding."
|
||||
icon: "diagram-project"
|
||||
mode: "wide"
|
||||
---
|
||||
|
||||
## Patterns
|
||||
|
||||
1. Read-first then write pattern
|
||||
2. Validation gate before side effects
|
||||
3. Fallback tool chains for degraded mode
|
||||
22
docs/en/ai/tools/reference.mdx
Normal file
22
docs/en/ai/tools/reference.mdx
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
title: "Tools: Reference"
|
||||
description: "Reference for tool invocation contracts, argument schemas, and runtime safeguards."
|
||||
icon: "book"
|
||||
mode: "wide"
|
||||
---
|
||||
|
||||
## Tool contract
|
||||
|
||||
- deterministic input schema
|
||||
- stable output schema
|
||||
- explicit error behavior
|
||||
|
||||
## Runtime safeguards
|
||||
|
||||
- timeout and retry policy
|
||||
- idempotency for side effects
|
||||
- validation before commit
|
||||
|
||||
## Canonical source
|
||||
|
||||
Primary API details live in [/en/concepts/tools](/en/concepts/tools).
|
||||
12
docs/en/ai/tools/troubleshooting.mdx
Normal file
12
docs/en/ai/tools/troubleshooting.mdx
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
title: "Tools: Troubleshooting"
|
||||
description: "Common tool-call failures and fixes for schema mismatch, retries, and side effects."
|
||||
icon: "circle-exclamation"
|
||||
mode: "wide"
|
||||
---
|
||||
|
||||
## Common issues
|
||||
|
||||
- Schema mismatch: align tool args with declared model output schema.
|
||||
- Repeated side effects: add idempotency keys.
|
||||
- Tool timeouts: define retries with bounded backoff.
|
||||
@@ -23,6 +23,17 @@ In the CrewAI framework, an `Agent` is an autonomous unit that can:
|
||||
at creating content.
|
||||
</Tip>
|
||||
|
||||
## When to Use Agents
|
||||
|
||||
- You need role-specific reasoning and decision-making.
|
||||
- You need tool-enabled execution with delegated responsibilities.
|
||||
- You need reusable behavioral units across tasks and crews.
|
||||
|
||||
## When Not to Use Agents
|
||||
|
||||
- Deterministic business logic in plain code is sufficient.
|
||||
- A static transformation without reasoning is sufficient.
|
||||
|
||||
<Note type="info" title="Enterprise Enhancement: Visual Agent Builder">
|
||||
CrewAI AMP includes a Visual Agent Builder that simplifies agent creation and configuration without writing code. Design your agents visually and test them in real-time.
|
||||
|
||||
|
||||
@@ -9,6 +9,17 @@ mode: "wide"
|
||||
|
||||
A crew in crewAI represents a collaborative group of agents working together to achieve a set of tasks. Each crew defines the strategy for task execution, agent collaboration, and the overall workflow.
|
||||
|
||||
## When to Use Crews
|
||||
|
||||
- You need multiple specialized agents collaborating on a shared outcome.
|
||||
- You need process-level orchestration (`sequential` or `hierarchical`).
|
||||
- You need task-level handoffs and context propagation.
|
||||
|
||||
## When Not to Use Crews
|
||||
|
||||
- A single agent can complete the work end-to-end.
|
||||
- You do not need multi-step task decomposition.
|
||||
|
||||
## Crew Attributes
|
||||
|
||||
| Attribute | Parameters | Description |
|
||||
@@ -417,3 +428,17 @@ crewai replay -t <task_id>
|
||||
```
|
||||
|
||||
These commands let you replay from your latest kickoff tasks, still retaining context from previously executed tasks.
|
||||
|
||||
## Common Failure Modes
|
||||
|
||||
### Agents overlap responsibilities
|
||||
- Cause: role/goal definitions are too broad.
|
||||
- Fix: tighten role boundaries and task ownership.
|
||||
|
||||
### Hierarchical runs stall or degrade
|
||||
- Cause: weak manager configuration or unclear delegation criteria.
|
||||
- Fix: define a stronger manager objective and explicit completion criteria.
|
||||
|
||||
### Crew outputs are inconsistent
|
||||
- Cause: expected outputs are underspecified across tasks.
|
||||
- Fix: enforce structured outputs and stronger task contracts.
|
||||
|
||||
@@ -19,82 +19,121 @@ Flows allow you to create structured, event-driven workflows. They provide a sea
|
||||
|
||||
4. **Flexible Control Flow**: Implement conditional logic, loops, and branching within your workflows.
|
||||
|
||||
## When to Use Flows
|
||||
|
||||
- You need deterministic orchestration and branching logic.
|
||||
- You need explicit state transitions across multiple steps.
|
||||
- You need resumable workflows with persistence.
|
||||
- You need to combine crews, direct model calls, and Python logic in one runtime.
|
||||
|
||||
## When Not to Use Flows
|
||||
|
||||
- A single prompt/response call is sufficient.
|
||||
- A single crew kickoff with no orchestration logic is sufficient.
|
||||
- You do not need stateful multi-step execution.
|
||||
|
||||
## Getting Started
|
||||
|
||||
Let's create a simple Flow where you will use OpenAI to generate a random city in one task and then use that city to generate a fun fact in another task.
|
||||
The example below shows a realistic Flow for support-ticket triage. It demonstrates features teams use in production: typed state, routing, memory access, and persistence.
|
||||
|
||||
```python Code
|
||||
|
||||
from crewai.flow.flow import Flow, listen, start
|
||||
from dotenv import load_dotenv
|
||||
from litellm import completion
|
||||
from crewai.flow.flow import Flow, listen, router, start
|
||||
from crewai.flow.persistence import persist
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class ExampleFlow(Flow):
|
||||
model = "gpt-4o-mini"
|
||||
class SupportTriageState(BaseModel):
|
||||
ticket_id: str = ""
|
||||
customer_tier: str = "standard" # standard | enterprise
|
||||
issue: str = ""
|
||||
urgency: str = "normal"
|
||||
route: str = ""
|
||||
draft_reply: str = ""
|
||||
internal_notes: list[str] = Field(default_factory=list)
|
||||
|
||||
|
||||
@persist()
|
||||
class SupportTriageFlow(Flow[SupportTriageState]):
|
||||
@start()
|
||||
def generate_city(self):
|
||||
print("Starting flow")
|
||||
# Each flow state automatically gets a unique ID
|
||||
print(f"Flow State ID: {self.state['id']}")
|
||||
def ingest_ticket(self):
|
||||
# kickoff(inputs={...}) is merged into typed state fields
|
||||
print(f"Flow State ID: {self.state.id}")
|
||||
|
||||
response = completion(
|
||||
model=self.model,
|
||||
messages=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Return the name of a random city in the world.",
|
||||
},
|
||||
],
|
||||
self.remember(
|
||||
f"Ticket {self.state.ticket_id}: {self.state.issue}",
|
||||
scope=f"/support/{self.state.ticket_id}",
|
||||
)
|
||||
|
||||
random_city = response["choices"][0]["message"]["content"]
|
||||
# Store the city in our state
|
||||
self.state["city"] = random_city
|
||||
print(f"Random City: {random_city}")
|
||||
issue = self.state.issue.lower()
|
||||
if "security" in issue or "breach" in issue:
|
||||
self.state.urgency = "critical"
|
||||
elif self.state.customer_tier == "enterprise":
|
||||
self.state.urgency = "high"
|
||||
else:
|
||||
self.state.urgency = "normal"
|
||||
|
||||
return random_city
|
||||
return self.state.issue
|
||||
|
||||
@listen(generate_city)
|
||||
def generate_fun_fact(self, random_city):
|
||||
response = completion(
|
||||
model=self.model,
|
||||
messages=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": f"Tell me a fun fact about {random_city}",
|
||||
},
|
||||
],
|
||||
@router(ingest_ticket)
|
||||
def route_ticket(self):
|
||||
issue = self.state.issue.lower()
|
||||
if "security" in issue or "breach" in issue:
|
||||
self.state.route = "security"
|
||||
return "security_review"
|
||||
if self.state.customer_tier == "enterprise" or self.state.urgency == "high":
|
||||
self.state.route = "priority"
|
||||
return "priority_queue"
|
||||
self.state.route = "standard"
|
||||
return "standard_queue"
|
||||
|
||||
@listen("security_review")
|
||||
def handle_security(self):
|
||||
self.state.internal_notes.append("Escalated to Security Incident Response")
|
||||
self.state.draft_reply = (
|
||||
"We have escalated your case to our security team and will update you shortly."
|
||||
)
|
||||
return self.state.draft_reply
|
||||
|
||||
fun_fact = response["choices"][0]["message"]["content"]
|
||||
# Store the fun fact in our state
|
||||
self.state["fun_fact"] = fun_fact
|
||||
return fun_fact
|
||||
@listen("priority_queue")
|
||||
def handle_priority(self):
|
||||
history = self.recall("SLA commitments for enterprise support", limit=2)
|
||||
self.state.internal_notes.append(
|
||||
f"Loaded {len(history)} memory hits for priority handling"
|
||||
)
|
||||
self.state.draft_reply = (
|
||||
"Your ticket has been prioritized and assigned to a senior support engineer."
|
||||
)
|
||||
return self.state.draft_reply
|
||||
|
||||
@listen("standard_queue")
|
||||
def handle_standard(self):
|
||||
self.state.internal_notes.append("Routed to standard support queue")
|
||||
self.state.draft_reply = "Thanks for reporting this. Our team will follow up soon."
|
||||
return self.state.draft_reply
|
||||
|
||||
|
||||
|
||||
flow = ExampleFlow()
|
||||
flow.plot()
|
||||
result = flow.kickoff()
|
||||
|
||||
print(f"Generated fun fact: {result}")
|
||||
flow = SupportTriageFlow()
|
||||
flow.plot("support_triage_flow")
|
||||
result = flow.kickoff(
|
||||
inputs={
|
||||
"ticket_id": "TCK-1024",
|
||||
"customer_tier": "enterprise",
|
||||
"issue": "Cannot access SSO after enabling new policy",
|
||||
}
|
||||
)
|
||||
print("Final reply:", result)
|
||||
print("Route:", flow.state.route)
|
||||
print("Notes:", flow.state.internal_notes)
|
||||
```
|
||||

|
||||
In the above example, we have created a simple Flow that generates a random city using OpenAI and then generates a fun fact about that city. The Flow consists of two tasks: `generate_city` and `generate_fun_fact`. The `generate_city` task is the starting point of the Flow, and the `generate_fun_fact` task listens for the output of the `generate_city` task.
|
||||
In this example, one flow demonstrates several core features together:
|
||||
1. `@start()` initializes and normalizes state for downstream steps.
|
||||
2. `@router()` performs deterministic branching into labeled routes.
|
||||
3. Route listeners implement lane-specific behavior (`security`, `priority`, `standard`).
|
||||
4. `@persist()` keeps the flow state recoverable between runs.
|
||||
5. Built-in memory methods (`remember`, `recall`) add durable context beyond a single method call.
|
||||
|
||||
Each Flow instance automatically receives a unique identifier (UUID) in its state, which helps track and manage flow executions. The state can also store additional data (like the generated city and fun fact) that persists throughout the flow's execution.
|
||||
|
||||
When you run the Flow, it will:
|
||||
1. Generate a unique ID for the flow state
|
||||
2. Generate a random city and store it in the state
|
||||
3. Generate a fun fact about that city and store it in the state
|
||||
4. Print the results to the console
|
||||
|
||||
The state's unique ID and stored data can be useful for tracking flow executions and maintaining context between tasks.
|
||||
|
||||
**Note:** Ensure you have set up your `.env` file to store your `OPENAI_API_KEY`. This key is necessary for authenticating requests to the OpenAI API.
|
||||
This pattern mirrors typical production workflows where request classification, policy-aware routing, and auditable state all happen in one orchestrated flow.
|
||||
|
||||
### @start()
|
||||
|
||||
@@ -117,15 +156,15 @@ The `@listen()` decorator can be used in several ways:
|
||||
1. **Listening to a Method by Name**: You can pass the name of the method you want to listen to as a string. When that method completes, the listener method will be triggered.
|
||||
|
||||
```python Code
|
||||
@listen("generate_city")
|
||||
def generate_fun_fact(self, random_city):
|
||||
@listen("upstream_method")
|
||||
def downstream_method(self, upstream_result):
|
||||
# Implementation
|
||||
```
|
||||
|
||||
2. **Listening to a Method Directly**: You can pass the method itself. When that method completes, the listener method will be triggered.
|
||||
```python Code
|
||||
@listen(generate_city)
|
||||
def generate_fun_fact(self, random_city):
|
||||
@listen(upstream_method)
|
||||
def downstream_method(self, upstream_result):
|
||||
# Implementation
|
||||
```
|
||||
|
||||
@@ -741,201 +780,17 @@ This example demonstrates several key features of using Agents in flows:
|
||||
|
||||
3. **Tool Integration**: Agents can use tools (like `WebsiteSearchTool`) to enhance their capabilities.
|
||||
|
||||
## Adding Crews to Flows
|
||||
## Multi-Crew Flows and Plotting
|
||||
|
||||
Creating a flow with multiple crews in CrewAI is straightforward.
|
||||
Detailed build walkthroughs and project scaffolding are documented in guide pages to keep this concepts page focused.
|
||||
|
||||
You can generate a new CrewAI project that includes all the scaffolding needed to create a flow with multiple crews by running the following command:
|
||||
- Build your first flow: [/en/guides/flows/first-flow](/en/guides/flows/first-flow)
|
||||
- Master state and persistence: [/en/guides/flows/mastering-flow-state](/en/guides/flows/mastering-flow-state)
|
||||
- Real-world chat-state pattern: [/en/learn/flowstate-chat-history](/en/learn/flowstate-chat-history)
|
||||
|
||||
```bash
|
||||
crewai create flow name_of_flow
|
||||
```
|
||||
|
||||
This command will generate a new CrewAI project with the necessary folder structure. The generated project includes a prebuilt crew called `poem_crew` that is already working. You can use this crew as a template by copying, pasting, and editing it to create other crews.
|
||||
|
||||
### Folder Structure
|
||||
|
||||
After running the `crewai create flow name_of_flow` command, you will see a folder structure similar to the following:
|
||||
|
||||
| Directory/File | Description |
|
||||
| :--------------------- | :----------------------------------------------------------------- |
|
||||
| `name_of_flow/` | Root directory for the flow. |
|
||||
| ├── `crews/` | Contains directories for specific crews. |
|
||||
| │ └── `poem_crew/` | Directory for the "poem_crew" with its configurations and scripts. |
|
||||
| │ ├── `config/` | Configuration files directory for the "poem_crew". |
|
||||
| │ │ ├── `agents.yaml` | YAML file defining the agents for "poem_crew". |
|
||||
| │ │ └── `tasks.yaml` | YAML file defining the tasks for "poem_crew". |
|
||||
| │ ├── `poem_crew.py` | Script for "poem_crew" functionality. |
|
||||
| ├── `tools/` | Directory for additional tools used in the flow. |
|
||||
| │ └── `custom_tool.py` | Custom tool implementation. |
|
||||
| ├── `main.py` | Main script for running the flow. |
|
||||
| ├── `README.md` | Project description and instructions. |
|
||||
| ├── `pyproject.toml` | Configuration file for project dependencies and settings. |
|
||||
| └── `.gitignore` | Specifies files and directories to ignore in version control. |
|
||||
|
||||
### Building Your Crews
|
||||
|
||||
In the `crews` folder, you can define multiple crews. Each crew will have its own folder containing configuration files and the crew definition file. For example, the `poem_crew` folder contains:
|
||||
|
||||
- `config/agents.yaml`: Defines the agents for the crew.
|
||||
- `config/tasks.yaml`: Defines the tasks for the crew.
|
||||
- `poem_crew.py`: Contains the crew definition, including agents, tasks, and the crew itself.
|
||||
|
||||
You can copy, paste, and edit the `poem_crew` to create other crews.
|
||||
|
||||
### Connecting Crews in `main.py`
|
||||
|
||||
The `main.py` file is where you create your flow and connect the crews together. You can define your flow by using the `Flow` class and the decorators `@start` and `@listen` to specify the flow of execution.
|
||||
|
||||
Here's an example of how you can connect the `poem_crew` in the `main.py` file:
|
||||
|
||||
```python Code
|
||||
#!/usr/bin/env python
|
||||
from random import randint
|
||||
|
||||
from pydantic import BaseModel
|
||||
from crewai.flow.flow import Flow, listen, start
|
||||
from .crews.poem_crew.poem_crew import PoemCrew
|
||||
|
||||
class PoemState(BaseModel):
|
||||
sentence_count: int = 1
|
||||
poem: str = ""
|
||||
|
||||
class PoemFlow(Flow[PoemState]):
|
||||
|
||||
@start()
|
||||
def generate_sentence_count(self):
|
||||
print("Generating sentence count")
|
||||
self.state.sentence_count = randint(1, 5)
|
||||
|
||||
@listen(generate_sentence_count)
|
||||
def generate_poem(self):
|
||||
print("Generating poem")
|
||||
result = PoemCrew().crew().kickoff(inputs={"sentence_count": self.state.sentence_count})
|
||||
|
||||
print("Poem generated", result.raw)
|
||||
self.state.poem = result.raw
|
||||
|
||||
@listen(generate_poem)
|
||||
def save_poem(self):
|
||||
print("Saving poem")
|
||||
with open("poem.txt", "w") as f:
|
||||
f.write(self.state.poem)
|
||||
|
||||
def kickoff():
|
||||
poem_flow = PoemFlow()
|
||||
poem_flow.kickoff()
|
||||
|
||||
|
||||
def plot():
|
||||
poem_flow = PoemFlow()
|
||||
poem_flow.plot("PoemFlowPlot")
|
||||
|
||||
if __name__ == "__main__":
|
||||
kickoff()
|
||||
plot()
|
||||
```
|
||||
|
||||
In this example, the `PoemFlow` class defines a flow that generates a sentence count, uses the `PoemCrew` to generate a poem, and then saves the poem to a file. The flow is kicked off by calling the `kickoff()` method. The PoemFlowPlot will be generated by `plot()` method.
|
||||
|
||||

|
||||
|
||||
### Running the Flow
|
||||
|
||||
(Optional) Before running the flow, you can install the dependencies by running:
|
||||
|
||||
```bash
|
||||
crewai install
|
||||
```
|
||||
|
||||
Once all of the dependencies are installed, you need to activate the virtual environment by running:
|
||||
|
||||
```bash
|
||||
source .venv/bin/activate
|
||||
```
|
||||
|
||||
After activating the virtual environment, you can run the flow by executing one of the following commands:
|
||||
|
||||
```bash
|
||||
crewai flow kickoff
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```bash
|
||||
uv run kickoff
|
||||
```
|
||||
|
||||
The flow will execute, and you should see the output in the console.
|
||||
|
||||
## Plot Flows
|
||||
|
||||
Visualizing your AI workflows can provide valuable insights into the structure and execution paths of your flows. CrewAI offers a powerful visualization tool that allows you to generate interactive plots of your flows, making it easier to understand and optimize your AI workflows.
|
||||
|
||||
### What are Plots?
|
||||
|
||||
Plots in CrewAI are graphical representations of your AI workflows. They display the various tasks, their connections, and the flow of data between them. This visualization helps in understanding the sequence of operations, identifying bottlenecks, and ensuring that the workflow logic aligns with your expectations.
|
||||
|
||||
### How to Generate a Plot
|
||||
|
||||
CrewAI provides two convenient methods to generate plots of your flows:
|
||||
|
||||
#### Option 1: Using the `plot()` Method
|
||||
|
||||
If you are working directly with a flow instance, you can generate a plot by calling the `plot()` method on your flow object. This method will create an HTML file containing the interactive plot of your flow.
|
||||
|
||||
```python Code
|
||||
# Assuming you have a flow instance
|
||||
flow.plot("my_flow_plot")
|
||||
```
|
||||
|
||||
This will generate a file named `my_flow_plot.html` in your current directory. You can open this file in a web browser to view the interactive plot.
|
||||
|
||||
#### Option 2: Using the Command Line
|
||||
|
||||
If you are working within a structured CrewAI project, you can generate a plot using the command line. This is particularly useful for larger projects where you want to visualize the entire flow setup.
|
||||
|
||||
```bash
|
||||
crewai flow plot
|
||||
```
|
||||
|
||||
This command will generate an HTML file with the plot of your flow, similar to the `plot()` method. The file will be saved in your project directory, and you can open it in a web browser to explore the flow.
|
||||
|
||||
### Understanding the Plot
|
||||
|
||||
The generated plot will display nodes representing the tasks in your flow, with directed edges indicating the flow of execution. The plot is interactive, allowing you to zoom in and out, and hover over nodes to see additional details.
|
||||
|
||||
By visualizing your flows, you can gain a clearer understanding of the workflow's structure, making it easier to debug, optimize, and communicate your AI processes to others.
|
||||
|
||||
### Conclusion
|
||||
|
||||
Plotting your flows is a powerful feature of CrewAI that enhances your ability to design and manage complex AI workflows. Whether you choose to use the `plot()` method or the command line, generating plots will provide you with a visual representation of your workflows, aiding in both development and presentation.
|
||||
|
||||
## Next Steps
|
||||
|
||||
If you're interested in exploring additional examples of flows, we have a variety of recommendations in our examples repository. Here are four specific flow examples, each showcasing unique use cases to help you match your current problem type to a specific example:
|
||||
|
||||
1. **Email Auto Responder Flow**: This example demonstrates an infinite loop where a background job continually runs to automate email responses. It's a great use case for tasks that need to be performed repeatedly without manual intervention. [View Example](https://github.com/crewAIInc/crewAI-examples/tree/main/email_auto_responder_flow)
|
||||
|
||||
2. **Lead Score Flow**: This flow showcases adding human-in-the-loop feedback and handling different conditional branches using the router. It's an excellent example of how to incorporate dynamic decision-making and human oversight into your workflows. [View Example](https://github.com/crewAIInc/crewAI-examples/tree/main/lead-score-flow)
|
||||
|
||||
3. **Write a Book Flow**: This example excels at chaining multiple crews together, where the output of one crew is used by another. Specifically, one crew outlines an entire book, and another crew generates chapters based on the outline. Eventually, everything is connected to produce a complete book. This flow is perfect for complex, multi-step processes that require coordination between different tasks. [View Example](https://github.com/crewAIInc/crewAI-examples/tree/main/write_a_book_with_flows)
|
||||
|
||||
4. **Meeting Assistant Flow**: This flow demonstrates how to broadcast one event to trigger multiple follow-up actions. For instance, after a meeting is completed, the flow can update a Trello board, send a Slack message, and save the results. It's a great example of handling multiple outcomes from a single event, making it ideal for comprehensive task management and notification systems. [View Example](https://github.com/crewAIInc/crewAI-examples/tree/main/meeting_assistant_flow)
|
||||
|
||||
By exploring these examples, you can gain insights into how to leverage CrewAI Flows for various use cases, from automating repetitive tasks to managing complex, multi-step processes with dynamic decision-making and human feedback.
|
||||
|
||||
Also, check out our YouTube video on how to use flows in CrewAI below!
|
||||
|
||||
<iframe
|
||||
className="w-full aspect-video rounded-xl"
|
||||
src="https://www.youtube.com/embed/MTb5my6VOT8"
|
||||
title="CrewAI Flows overview"
|
||||
frameBorder="0"
|
||||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
|
||||
referrerPolicy="strict-origin-when-cross-origin"
|
||||
allowFullScreen
|
||||
></iframe>
|
||||
For visualization:
|
||||
- Use `flow.plot("my_flow_plot")` in code, or
|
||||
- Use `crewai flow plot` in CLI projects.
|
||||
|
||||
## Running Flows
|
||||
|
||||
@@ -946,7 +801,7 @@ There are two ways to run a flow:
|
||||
You can run a flow programmatically by creating an instance of your flow class and calling the `kickoff()` method:
|
||||
|
||||
```python
|
||||
flow = ExampleFlow()
|
||||
flow = SupportTriageFlow()
|
||||
result = flow.kickoff()
|
||||
```
|
||||
|
||||
@@ -1065,3 +920,21 @@ crewai flow kickoff
|
||||
```
|
||||
|
||||
However, the `crewai run` command is now the preferred method as it works for both crews and flows.
|
||||
|
||||
## Common Failure Modes
|
||||
|
||||
### Router branch not firing
|
||||
- Cause: returned label does not match a `@listen("label")` value.
|
||||
- Fix: align router return strings with listener labels exactly.
|
||||
|
||||
### State fields missing at runtime
|
||||
- Cause: untyped dynamic fields or missing kickoff inputs.
|
||||
- Fix: use typed state and validate required fields in `@start()`.
|
||||
|
||||
### Prompt/token growth over time
|
||||
- Cause: appending unbounded message history in state.
|
||||
- Fix: apply sliding-window state and summary compaction patterns.
|
||||
|
||||
### Non-idempotent retries
|
||||
- Cause: side effects executed on retried steps.
|
||||
- Fix: add idempotency keys/markers to state and guard external writes.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -156,6 +156,7 @@ class ResearchFlow(Flow):
|
||||
```
|
||||
|
||||
See the [Flows documentation](/concepts/flows) for more on memory in Flows.
|
||||
For a production-style conversational pattern that combines Flow state and memory, see [Flowstate Chat History](/en/learn/flowstate-chat-history).
|
||||
|
||||
|
||||
## Hierarchical Scopes
|
||||
|
||||
@@ -10,6 +10,17 @@ mode: "wide"
|
||||
The planning feature in CrewAI allows you to add planning capability to your crew. When enabled, before each Crew iteration,
|
||||
all Crew information is sent to an AgentPlanner that will plan the tasks step by step, and this plan will be added to each task description.
|
||||
|
||||
## When to Use Planning
|
||||
|
||||
- Tasks require multi-step decomposition before execution.
|
||||
- You need more consistent execution quality on complex tasks.
|
||||
- You want transparent planning traces in crew runs.
|
||||
|
||||
## When Not to Use Planning
|
||||
|
||||
- Tasks are simple and deterministic.
|
||||
- Latency and token budget are strict and planning overhead is not justified.
|
||||
|
||||
### Using the Planning Feature
|
||||
|
||||
Getting started with the planning feature is very easy, the only step required is to add `planning=True` to your Crew:
|
||||
@@ -31,7 +42,7 @@ my_crew = Crew(
|
||||
From this point on, your crew will have planning enabled, and the tasks will be planned before each iteration.
|
||||
|
||||
<Warning>
|
||||
When planning is enabled, crewAI will use `gpt-4o-mini` as the default LLM for planning, which requires a valid OpenAI API key. Since your agents might be using different LLMs, this could cause confusion if you don't have an OpenAI API key configured or if you're experiencing unexpected behavior related to LLM API calls.
|
||||
Planning model defaults can vary by version and environment. To avoid implicit provider dependencies, set `planning_llm` explicitly in your crew configuration.
|
||||
</Warning>
|
||||
|
||||
#### Planning LLM
|
||||
@@ -152,4 +163,14 @@ A list with 10 bullet points of the most relevant information about AI LLMs.
|
||||
**Expected Output:**
|
||||
A fully fledged report with the main topics, each with a full section of information. Formatted as markdown without '```'.
|
||||
```
|
||||
</CodeGroup>
|
||||
</CodeGroup>
|
||||
|
||||
## Common Failure Modes
|
||||
|
||||
### Planning adds cost/latency without quality gains
|
||||
- Cause: planning enabled for simple tasks.
|
||||
- Fix: disable `planning` for straightforward pipelines.
|
||||
|
||||
### Unexpected provider authentication errors
|
||||
- Cause: implicit planner model/provider assumptions.
|
||||
- Fix: set `planning_llm` explicitly and ensure matching credentials are configured.
|
||||
|
||||
@@ -12,11 +12,20 @@ mode: "wide"
|
||||
These processes ensure tasks are distributed and executed efficiently, in alignment with a predefined strategy.
|
||||
</Tip>
|
||||
|
||||
## When to Use Each Process
|
||||
|
||||
- Use `sequential` when task order is fixed and outputs feed directly into the next task.
|
||||
- Use `hierarchical` when you need a manager to delegate and validate work dynamically.
|
||||
|
||||
## When Not to Use Hierarchical
|
||||
|
||||
- You do not need dynamic delegation.
|
||||
- You cannot provide a reliable `manager_llm` or `manager_agent`.
|
||||
|
||||
## Process Implementations
|
||||
|
||||
- **Sequential**: Executes tasks sequentially, ensuring tasks are completed in an orderly progression.
|
||||
- **Hierarchical**: Organizes tasks in a managerial hierarchy, where tasks are delegated and executed based on a structured chain of command. A manager language model (`manager_llm`) or a custom manager agent (`manager_agent`) must be specified in the crew to enable the hierarchical process, facilitating the creation and management of tasks by the manager.
|
||||
- **Consensual Process (Planned)**: Aiming for collaborative decision-making among agents on task execution, this process type introduces a democratic approach to task management within CrewAI. It is planned for future development and is not currently implemented in the codebase.
|
||||
|
||||
## The Role of Processes in Teamwork
|
||||
Processes enable individual agents to operate as a cohesive unit, streamlining their efforts to achieve common objectives with efficiency and coherence.
|
||||
@@ -59,9 +68,17 @@ Emulates a corporate hierarchy, CrewAI allows specifying a custom manager agent
|
||||
|
||||
## Process Class: Detailed Overview
|
||||
|
||||
The `Process` class is implemented as an enumeration (`Enum`), ensuring type safety and restricting process values to the defined types (`sequential`, `hierarchical`). The consensual process is planned for future inclusion, emphasizing our commitment to continuous development and innovation.
|
||||
The `Process` class is implemented as an enumeration (`Enum`), ensuring type safety and restricting process values to the defined types (`sequential`, `hierarchical`).
|
||||
|
||||
## Conclusion
|
||||
|
||||
The structured collaboration facilitated by processes within CrewAI is crucial for enabling systematic teamwork among agents.
|
||||
This documentation has been updated to reflect the latest features, enhancements, and the planned integration of the Consensual Process, ensuring users have access to the most current and comprehensive information.
|
||||
## Common Failure Modes
|
||||
|
||||
### Hierarchical process fails at startup
|
||||
- Cause: missing `manager_llm` or `manager_agent`.
|
||||
- Fix: provide one of them explicitly in crew configuration.
|
||||
|
||||
### Sequential process produces weak outputs
|
||||
- Cause: task boundaries/context are underspecified.
|
||||
- Fix: improve task descriptions, expected outputs, and task context chaining.
|
||||
|
||||
@@ -9,9 +9,20 @@ mode: "wide"
|
||||
|
||||
Testing is a crucial part of the development process, and it is essential to ensure that your crew is performing as expected. With crewAI, you can easily test your crew and evaluate its performance using the built-in testing capabilities.
|
||||
|
||||
## When to Use Testing
|
||||
|
||||
- Before promoting a crew to production.
|
||||
- After changing prompts, tools, or model configurations.
|
||||
- When benchmarking quality/cost/latency tradeoffs.
|
||||
|
||||
## When Not to Rely on Testing Alone
|
||||
|
||||
- For safety-critical deployments without human review gates.
|
||||
- When test datasets are too small or unrepresentative.
|
||||
|
||||
### Using the Testing Feature
|
||||
|
||||
We added the CLI command `crewai test` to make it easy to test your crew. This command will run your crew for a specified number of iterations and provide detailed performance metrics. The parameters are `n_iterations` and `model`, which are optional and default to 2 and `gpt-4o-mini` respectively. For now, the only provider available is OpenAI.
|
||||
Use the CLI command `crewai test` to run repeated crew executions and compare outputs across iterations. The parameters are `n_iterations` and `model`, which are optional and default to `2` and `gpt-4o-mini`.
|
||||
|
||||
```bash
|
||||
crewai test
|
||||
@@ -47,3 +58,13 @@ A table of scores at the end will show the performance of the crew in terms of t
|
||||
| Execution Time (s) | 126 | 145 | **135** | | |
|
||||
|
||||
The example above shows the test results for two runs of the crew with two tasks, with the average total score for each task and the crew as a whole.
|
||||
|
||||
## Common Failure Modes
|
||||
|
||||
### Scores fluctuate too much between runs
|
||||
- Cause: high sampling randomness or unstable prompts.
|
||||
- Fix: lower temperature and tighten output constraints.
|
||||
|
||||
### Good test scores but poor production quality
|
||||
- Cause: test prompts do not match real workload.
|
||||
- Fix: build a representative test set from real production inputs.
|
||||
|
||||
@@ -10,6 +10,17 @@ mode: "wide"
|
||||
CrewAI tools empower agents with capabilities ranging from web searching and data analysis to collaboration and delegating tasks among coworkers.
|
||||
This documentation outlines how to create, integrate, and leverage these tools within the CrewAI framework, including a new focus on collaboration tools.
|
||||
|
||||
## When to Use Tools
|
||||
|
||||
- Agents need external data or side effects.
|
||||
- You need deterministic actions wrapped in reusable interfaces.
|
||||
- You need to connect APIs, files, databases, or browser actions into agent workflows.
|
||||
|
||||
## When Not to Use Tools
|
||||
|
||||
- The task can be solved entirely from prompt context.
|
||||
- The external side effect cannot be made safe or idempotent.
|
||||
|
||||
## What is a Tool?
|
||||
|
||||
A tool in CrewAI is a skill or function that agents can utilize to perform various actions.
|
||||
@@ -285,3 +296,17 @@ writer1 = Agent(
|
||||
Tools are pivotal in extending the capabilities of CrewAI agents, enabling them to undertake a broad spectrum of tasks and collaborate effectively.
|
||||
When building solutions with CrewAI, leverage both custom and existing tools to empower your agents and enhance the AI ecosystem. Consider utilizing error handling,
|
||||
caching mechanisms, and the flexibility of tool arguments to optimize your agents' performance and capabilities.
|
||||
|
||||
## Common Failure Modes
|
||||
|
||||
### Tool schema mismatch
|
||||
- Cause: model-generated arguments do not match tool signature.
|
||||
- Fix: tighten tool descriptions and validate input schemas.
|
||||
|
||||
### Repeated side effects
|
||||
- Cause: retries trigger duplicate writes/actions.
|
||||
- Fix: add idempotency keys and deduplication checks in tool logic.
|
||||
|
||||
### Tool timeouts under load
|
||||
- Cause: unbounded retries or slow external services.
|
||||
- Fix: set explicit timeout/retry policy and graceful fallbacks.
|
||||
|
||||
@@ -38,22 +38,21 @@ CrewAI Enterprise provides a comprehensive Human-in-the-Loop (HITL) management s
|
||||
Configure human review checkpoints within your Flows using the `@human_feedback` decorator. When execution reaches a review point, the system pauses, notifies the assignee via email, and waits for a response.
|
||||
|
||||
```python
|
||||
from crewai.flow.flow import Flow, start, listen
|
||||
from crewai.flow.flow import Flow, start, listen, or_
|
||||
from crewai.flow.human_feedback import human_feedback, HumanFeedbackResult
|
||||
|
||||
class ContentApprovalFlow(Flow):
|
||||
@start()
|
||||
def generate_content(self):
|
||||
# AI generates content
|
||||
return "Generated marketing copy for Q1 campaign..."
|
||||
|
||||
@listen(generate_content)
|
||||
@human_feedback(
|
||||
message="Please review this content for brand compliance:",
|
||||
emit=["approved", "rejected", "needs_revision"],
|
||||
)
|
||||
def review_content(self, content):
|
||||
return content
|
||||
@listen(or_("generate_content", "needs_revision"))
|
||||
def review_content(self):
|
||||
return "Marketing copy for review..."
|
||||
|
||||
@listen("approved")
|
||||
def publish_content(self, result: HumanFeedbackResult):
|
||||
@@ -62,10 +61,6 @@ class ContentApprovalFlow(Flow):
|
||||
@listen("rejected")
|
||||
def archive_content(self, result: HumanFeedbackResult):
|
||||
print(f"Content rejected. Reason: {result.feedback}")
|
||||
|
||||
@listen("needs_revision")
|
||||
def revise_content(self, result: HumanFeedbackResult):
|
||||
print(f"Revision requested: {result.feedback}")
|
||||
```
|
||||
|
||||
For complete implementation details, see the [Human Feedback in Flows](/en/learn/human-feedback-in-flows) guide.
|
||||
|
||||
@@ -8,6 +8,10 @@ mode: "wide"
|
||||
## Quickstarts & Demos
|
||||
|
||||
<CardGroup cols={3}>
|
||||
<Card title="Flowstate Chat History" icon="comments" href="/en/learn/flowstate-chat-history">
|
||||
Manage chat sessions with sliding-window history, summary compaction, and persisted Flow state.
|
||||
</Card>
|
||||
|
||||
<Card title="Collaboration" icon="people-arrows" href="https://github.com/crewAIInc/crewAI-quickstarts/blob/main/Collaboration/crewai_collaboration.ipynb">
|
||||
Coordinate multiple agents on shared tasks. Includes notebook with end-to-end collaboration pattern.
|
||||
</Card>
|
||||
|
||||
@@ -34,6 +34,10 @@ mode: "wide"
|
||||
## Flows
|
||||
|
||||
<CardGroup cols={3}>
|
||||
<Card title="Flowstate Chat History" icon="comments" href="/en/learn/flowstate-chat-history">
|
||||
Stateful chat pattern with compacted context and persisted session state.
|
||||
</Card>
|
||||
|
||||
<Card title="Content Creator Flow" icon="pen" href="https://github.com/crewAIInc/crewAI-examples/tree/main/flows/content_creator_flow">
|
||||
Multi‑crew content generation with routing.
|
||||
</Card>
|
||||
|
||||
@@ -47,6 +47,23 @@ CrewAI offers two ways to manage state in your flows:
|
||||
|
||||
Let's examine each approach in detail.
|
||||
|
||||
### Flow State vs Memory: When to use each
|
||||
|
||||
Both features keep context, but they solve different problems.
|
||||
|
||||
| Dimension | Flow State (`self.state`) | Memory (`self.remember` / `self.recall`) |
|
||||
|---|---|---|
|
||||
| Primary purpose | Track execution and deterministic workflow data | Store and retrieve semantic knowledge across interactions |
|
||||
| Data shape | Explicit fields (dict/Pydantic model) | Text records with inferred scopes and ranked recall |
|
||||
| Typical lifetime | Current flow run (or persisted checkpoints) | Long-term knowledge over many runs |
|
||||
| Access pattern | Direct reads/writes (`self.state.field`) | Query-based retrieval (`self.recall("...")`) |
|
||||
| Best for | Routing flags, counters, intermediate outputs, chat window | Durable facts, prior outcomes, reusable context |
|
||||
| Chat use | Recent turns + running summary + control flags | Long-tail memory outside context window |
|
||||
|
||||
Practical rule:
|
||||
- Use **state** for what your control flow depends on right now.
|
||||
- Use **memory** for what you may want to retrieve later by meaning.
|
||||
|
||||
## Unstructured State Management
|
||||
|
||||
Unstructured state uses a dictionary-like approach, offering flexibility and simplicity for straightforward applications.
|
||||
|
||||
@@ -27,8 +27,11 @@ mode: "wide"
|
||||
</div>
|
||||
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 12, justifyContent: 'center' }}>
|
||||
<a className="button button-primary" href="/en/quickstart">Get started</a>
|
||||
<a className="button" href="/en/changelog">View changelog</a>
|
||||
<a className="button button-primary" href="/en/installation">Install</a>
|
||||
<a className="button" href="/en/quickstart">Quickstart</a>
|
||||
<a className="button" href="/en/guides/crews/first-crew">First Crew</a>
|
||||
<a className="button" href="/en/guides/flows/first-flow">First Flow</a>
|
||||
<a className="button" href="/en/concepts/llms">LLM Setup</a>
|
||||
<a className="button" href="/en/api-reference/introduction">API Reference</a>
|
||||
</div>
|
||||
|
||||
@@ -36,17 +39,49 @@ mode: "wide"
|
||||
|
||||
<div style={{ marginTop: 32 }} />
|
||||
|
||||
## Get started
|
||||
## Start in 3 steps
|
||||
|
||||
<CardGroup cols={3}>
|
||||
<Card title="Introduction" href="/en/introduction" icon="sparkles">
|
||||
Overview of CrewAI concepts, architecture, and what you can build with agents, crews, and flows.
|
||||
</Card>
|
||||
<Card title="Installation" href="/en/installation" icon="wrench">
|
||||
<Card title="1) Install" href="/en/installation" icon="wrench">
|
||||
Install via `uv`, configure API keys, and set up the CLI for local development.
|
||||
</Card>
|
||||
<Card title="Quickstart" href="/en/quickstart" icon="rocket">
|
||||
Spin up your first crew in minutes. Learn the core runtime, project layout, and dev loop.
|
||||
<Card title="2) Run Quickstart" href="/en/quickstart" icon="rocket">
|
||||
Launch your first working crew with a minimal project and iterate from there.
|
||||
</Card>
|
||||
<Card title="3) Pick a path" href="/en/ai/overview" icon="sitemap">
|
||||
Continue with canonical domain packs for Flows, Agents, Crews, LLMs, Memory, and Tools.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
## Most-used pages
|
||||
|
||||
<CardGroup cols={3}>
|
||||
<Card title="First Crew" href="/en/guides/crews/first-crew" icon="users">
|
||||
Build a production-style crew with role/task configuration and execution flow.
|
||||
</Card>
|
||||
<Card title="First Flow" href="/en/guides/flows/first-flow" icon="arrow-progress">
|
||||
Build event-driven orchestration with state, listeners, and routing.
|
||||
</Card>
|
||||
<Card title="Flowstate Chat History" href="/en/learn/flowstate-chat-history" icon="comments">
|
||||
Stateful chat history pattern with persistence and summary compaction.
|
||||
</Card>
|
||||
<Card title="Agents" href="/en/concepts/agents" icon="user">
|
||||
Agent role design, tool boundaries, and output contracts.
|
||||
</Card>
|
||||
<Card title="Crews" href="/en/concepts/crews" icon="users-gear">
|
||||
Multi-agent collaboration patterns and process semantics.
|
||||
</Card>
|
||||
<Card title="Flows" href="/en/concepts/flows" icon="code-branch">
|
||||
Deterministic orchestration, state lifecycle, persistence, and resume.
|
||||
</Card>
|
||||
<Card title="LLMs" href="/en/concepts/llms" icon="microchip-ai">
|
||||
Model setup, provider config, routing patterns, and reliability defaults.
|
||||
</Card>
|
||||
<Card title="Memory" href="/en/concepts/memory" icon="database">
|
||||
Semantic recall, scope strategy, and state-vs-memory architecture.
|
||||
</Card>
|
||||
<Card title="Tools" href="/en/tools/overview" icon="wrench">
|
||||
Tool categories, integration surfaces, and practical usage patterns.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
@@ -90,7 +125,11 @@ mode: "wide"
|
||||
</CardGroup>
|
||||
|
||||
<Callout title="Explore real-world patterns" icon="github">
|
||||
Browse the <a href="/en/examples/cookbooks">examples and cookbooks</a> for end-to-end reference implementations across agents, flows, and enterprise automations.
|
||||
Browse the <a href="/en/examples/cookbooks">examples and cookbooks</a> for end-to-end reference implementations across agents, flows, and enterprise automations. For a practical conversational pattern, start with <a href="/en/learn/flowstate-chat-history">Flowstate Chat History</a>.
|
||||
</Callout>
|
||||
|
||||
<Callout title="AI-First Docs" icon="sitemap">
|
||||
Use the <a href="/en/ai/overview">AI-First Documentation map</a> for canonical domain packs across Flows, Agents, Crews, LLMs, Memory, and Tools.
|
||||
</Callout>
|
||||
|
||||
## Stay connected
|
||||
|
||||
@@ -16,6 +16,52 @@ It empowers developers to build production-ready multi-agent systems by combinin
|
||||
|
||||
With over 100,000 developers certified through our community courses, CrewAI is the standard for enterprise-ready AI automation.
|
||||
|
||||
## Start Here
|
||||
|
||||
<CardGroup cols={3}>
|
||||
<Card title="Install" href="/en/installation" icon="wrench">
|
||||
Set up CrewAI, configure API keys, and prepare your local environment.
|
||||
</Card>
|
||||
<Card title="Quickstart" href="/en/quickstart" icon="rocket">
|
||||
Run your first working crew with a minimal setup.
|
||||
</Card>
|
||||
<Card title="First Crew" href="/en/guides/crews/first-crew" icon="users-gear">
|
||||
Build a production-style crew with roles, tasks, and execution flow.
|
||||
</Card>
|
||||
<Card title="First Flow" href="/en/guides/flows/first-flow" icon="arrow-progress">
|
||||
Build event-driven orchestration with state, listeners, and routers.
|
||||
</Card>
|
||||
<Card title="LLM Setup" href="/en/concepts/llms" icon="microchip-ai">
|
||||
Configure providers, models, and reliability defaults.
|
||||
</Card>
|
||||
<Card title="API Reference" href="/en/api-reference/introduction" icon="book">
|
||||
Use kickoff, resume, and status endpoints for production integrations.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
## Most-used Docs
|
||||
|
||||
<CardGroup cols={3}>
|
||||
<Card title="Agents" href="/en/concepts/agents" icon="user">
|
||||
Role design, tool boundaries, and output contracts.
|
||||
</Card>
|
||||
<Card title="Crews" href="/en/concepts/crews" icon="users">
|
||||
Multi-agent coordination and process choices.
|
||||
</Card>
|
||||
<Card title="Flows" href="/en/concepts/flows" icon="code-branch">
|
||||
Deterministic orchestration, state, persistence, and resume.
|
||||
</Card>
|
||||
<Card title="Memory" href="/en/concepts/memory" icon="database">
|
||||
Scope strategy and semantic recall across runs.
|
||||
</Card>
|
||||
<Card title="Flowstate Chat History" href="/en/learn/flowstate-chat-history" icon="comments">
|
||||
Stateful chat context with summary compaction and persistence.
|
||||
</Card>
|
||||
<Card title="AI-First Docs Map" href="/en/ai/overview" icon="sitemap">
|
||||
Canonical domain packs for Flows, Agents, Crews, LLMs, Memory, and Tools.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
## The CrewAI Architecture
|
||||
|
||||
CrewAI's architecture is designed to balance autonomy with control.
|
||||
@@ -130,7 +176,7 @@ For any production-ready application, **start with a Flow**.
|
||||
<Card
|
||||
title="Quick Start"
|
||||
icon="bolt"
|
||||
href="en/quickstart"
|
||||
href="/en/quickstart"
|
||||
>
|
||||
Follow our quickstart guide to create your first CrewAI agent and get hands-on experience.
|
||||
</Card>
|
||||
|
||||
167
docs/en/learn/flowstate-chat-history.mdx
Normal file
167
docs/en/learn/flowstate-chat-history.mdx
Normal file
@@ -0,0 +1,167 @@
|
||||
---
|
||||
title: "Flowstate Chat History"
|
||||
description: "Build a stateful chat workflow that keeps context compact, persistent, and production-friendly."
|
||||
icon: "comments"
|
||||
mode: "wide"
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
This guide shows a practical pattern for managing LLM chat history with Flow state:
|
||||
|
||||
- Keep recent turns in a sliding window
|
||||
- Summarize older turns into a compact running summary
|
||||
- Persist state automatically with `@persist()`
|
||||
- Keep optional long-term recall using Flow memory
|
||||
|
||||
## Why this pattern works
|
||||
|
||||
Naively appending every message to prompts causes token bloat and unstable behavior over long sessions. A better approach is:
|
||||
|
||||
1. Keep only the most recent turns in `state.messages`
|
||||
2. Move older turns into `state.running_summary`
|
||||
3. Build prompts from `running_summary + recent messages`
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. CrewAI installed and configured
|
||||
2. API key configured for your model provider
|
||||
3. Basic familiarity with Flow decorators (`@start`, `@listen`)
|
||||
|
||||
## Step 1: Define typed chat state
|
||||
|
||||
```python Code
|
||||
from typing import Dict, List
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class ChatSessionState(BaseModel):
|
||||
session_id: str = "demo-session"
|
||||
running_summary: str = ""
|
||||
messages: List[Dict[str, str]] = Field(default_factory=list)
|
||||
max_recent_messages: int = 8
|
||||
last_user_message: str = ""
|
||||
assistant_reply: str = ""
|
||||
turn_count: int = 0
|
||||
```
|
||||
|
||||
## Step 2: Build the Flow
|
||||
|
||||
```python Code
|
||||
from crewai.flow.flow import Flow, start, listen
|
||||
from crewai.flow.persistence import persist
|
||||
from litellm import completion
|
||||
|
||||
|
||||
@persist()
|
||||
class ChatHistoryFlow(Flow[ChatSessionState]):
|
||||
model = "gpt-4o-mini"
|
||||
|
||||
@start()
|
||||
def capture_user_message(self):
|
||||
self.state.last_user_message = self.state.last_user_message.strip()
|
||||
self.state.messages.append(
|
||||
{"role": "user", "content": self.state.last_user_message}
|
||||
)
|
||||
self.state.turn_count += 1
|
||||
return self.state.last_user_message
|
||||
|
||||
@listen(capture_user_message)
|
||||
def compact_old_history(self, _):
|
||||
if len(self.state.messages) <= self.state.max_recent_messages:
|
||||
return "no_compaction"
|
||||
|
||||
overflow = self.state.messages[:-self.state.max_recent_messages]
|
||||
self.state.messages = self.state.messages[-self.state.max_recent_messages :]
|
||||
overflow_text = "\n".join(
|
||||
f"{m['role']}: {m['content']}" for m in overflow
|
||||
)
|
||||
|
||||
summary_prompt = [
|
||||
{
|
||||
"role": "system",
|
||||
"content": "Summarize old chat turns into short bullet points. Preserve facts, constraints, and decisions.",
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": (
|
||||
f"Existing summary:\n{self.state.running_summary or '(empty)'}\n\n"
|
||||
f"New old turns:\n{overflow_text}"
|
||||
),
|
||||
},
|
||||
]
|
||||
summary_response = completion(model=self.model, messages=summary_prompt)
|
||||
self.state.running_summary = summary_response["choices"][0]["message"]["content"]
|
||||
return "compacted"
|
||||
|
||||
@listen(compact_old_history)
|
||||
def generate_reply(self, _):
|
||||
system_context = (
|
||||
"You are a helpful assistant.\n"
|
||||
f"Conversation summary so far:\n{self.state.running_summary or '(none)'}"
|
||||
)
|
||||
|
||||
response = completion(
|
||||
model=self.model,
|
||||
messages=[{"role": "system", "content": system_context}, *self.state.messages],
|
||||
)
|
||||
answer = response["choices"][0]["message"]["content"]
|
||||
|
||||
self.state.assistant_reply = answer
|
||||
self.state.messages.append({"role": "assistant", "content": answer})
|
||||
|
||||
# Optional: store key turns in long-term memory for later recall
|
||||
self.remember(
|
||||
f"Session {self.state.session_id} turn {self.state.turn_count}: "
|
||||
f"user={self.state.last_user_message} assistant={answer}",
|
||||
scope=f"/chat/{self.state.session_id}",
|
||||
)
|
||||
return answer
|
||||
```
|
||||
|
||||
## Step 3: Run it
|
||||
|
||||
```python Code
|
||||
flow = ChatHistoryFlow()
|
||||
|
||||
first = flow.kickoff(
|
||||
inputs={
|
||||
"session_id": "customer-42",
|
||||
"last_user_message": "I need help choosing a pricing plan for a 10-person team.",
|
||||
}
|
||||
)
|
||||
print("Assistant:", first)
|
||||
|
||||
second = flow.kickoff(
|
||||
inputs={
|
||||
"last_user_message": "We also need SSO and audit logs. What do you recommend now?",
|
||||
}
|
||||
)
|
||||
print("Assistant:", second)
|
||||
print("Turns:", flow.state.turn_count)
|
||||
print("Recent messages:", len(flow.state.messages))
|
||||
```
|
||||
|
||||
## Expected output (shape)
|
||||
|
||||
```text Output
|
||||
Assistant: ...initial recommendation...
|
||||
Assistant: ...updated recommendation with SSO and audit-log requirements...
|
||||
Turns: 2
|
||||
Recent messages: 4
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
- If replies ignore earlier context:
|
||||
increase `max_recent_messages` and ensure `running_summary` is included in the system context.
|
||||
- If prompts become too large:
|
||||
lower `max_recent_messages` and summarize more aggressively.
|
||||
- If sessions collide:
|
||||
provide a stable `session_id` and isolate memory scope with `/chat/{session_id}`.
|
||||
|
||||
## Next steps
|
||||
|
||||
- Add tool calls for account lookup or product catalog retrieval
|
||||
- Route to human review for high-risk decisions
|
||||
- Add structured output to capture recommendations in machine-readable JSON
|
||||
@@ -98,33 +98,43 @@ def handle_feedback(self, result):
|
||||
When you specify `emit`, the decorator becomes a router. The human's free-form feedback is interpreted by an LLM and collapsed into one of the specified outcomes:
|
||||
|
||||
```python Code
|
||||
@start()
|
||||
@human_feedback(
|
||||
message="Do you approve this content for publication?",
|
||||
emit=["approved", "rejected", "needs_revision"],
|
||||
llm="gpt-4o-mini",
|
||||
default_outcome="needs_revision",
|
||||
)
|
||||
def review_content(self):
|
||||
return "Draft blog post content here..."
|
||||
from crewai.flow.flow import Flow, start, listen, or_
|
||||
from crewai.flow.human_feedback import human_feedback
|
||||
|
||||
@listen("approved")
|
||||
def publish(self, result):
|
||||
print(f"Publishing! User said: {result.feedback}")
|
||||
class ReviewFlow(Flow):
|
||||
@start()
|
||||
def generate_content(self):
|
||||
return "Draft blog post content here..."
|
||||
|
||||
@listen("rejected")
|
||||
def discard(self, result):
|
||||
print(f"Discarding. Reason: {result.feedback}")
|
||||
@human_feedback(
|
||||
message="Do you approve this content for publication?",
|
||||
emit=["approved", "rejected", "needs_revision"],
|
||||
llm="gpt-4o-mini",
|
||||
default_outcome="needs_revision",
|
||||
)
|
||||
@listen(or_("generate_content", "needs_revision"))
|
||||
def review_content(self):
|
||||
return "Draft blog post content here..."
|
||||
|
||||
@listen("needs_revision")
|
||||
def revise(self, result):
|
||||
print(f"Revising based on: {result.feedback}")
|
||||
@listen("approved")
|
||||
def publish(self, result):
|
||||
print(f"Publishing! User said: {result.feedback}")
|
||||
|
||||
@listen("rejected")
|
||||
def discard(self, result):
|
||||
print(f"Discarding. Reason: {result.feedback}")
|
||||
```
|
||||
|
||||
When the human says something like "needs more detail", the LLM collapses that to `"needs_revision"`, which triggers `review_content` again via `or_()` — creating a revision loop. The loop continues until the outcome is `"approved"` or `"rejected"`.
|
||||
|
||||
<Tip>
|
||||
The LLM uses structured outputs (function calling) when available to guarantee the response is one of your specified outcomes. This makes routing reliable and predictable.
|
||||
</Tip>
|
||||
|
||||
<Warning>
|
||||
A `@start()` method only runs once at the beginning of the flow. If you need a revision loop, separate the start method from the review method and use `@listen(or_("trigger", "revision_outcome"))` on the review method to enable the self-loop.
|
||||
</Warning>
|
||||
|
||||
## HumanFeedbackResult
|
||||
|
||||
The `HumanFeedbackResult` dataclass contains all information about a human feedback interaction:
|
||||
@@ -188,127 +198,183 @@ Each `HumanFeedbackResult` is appended to `human_feedback_history`, so multiple
|
||||
|
||||
## Complete Example: Content Approval Workflow
|
||||
|
||||
Here's a full example implementing a content review and approval workflow:
|
||||
Here's a full example implementing a content review and approval workflow with a revision loop:
|
||||
|
||||
<CodeGroup>
|
||||
|
||||
```python Code
|
||||
from crewai.flow.flow import Flow, start, listen
|
||||
from crewai.flow.flow import Flow, start, listen, or_
|
||||
from crewai.flow.human_feedback import human_feedback, HumanFeedbackResult
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class ContentState(BaseModel):
|
||||
topic: str = ""
|
||||
draft: str = ""
|
||||
final_content: str = ""
|
||||
revision_count: int = 0
|
||||
status: str = "pending"
|
||||
|
||||
|
||||
class ContentApprovalFlow(Flow[ContentState]):
|
||||
"""A flow that generates content and gets human approval."""
|
||||
"""A flow that generates content and loops until the human approves."""
|
||||
|
||||
@start()
|
||||
def get_topic(self):
|
||||
self.state.topic = input("What topic should I write about? ")
|
||||
return self.state.topic
|
||||
|
||||
@listen(get_topic)
|
||||
def generate_draft(self, topic):
|
||||
# In real use, this would call an LLM
|
||||
self.state.draft = f"# {topic}\n\nThis is a draft about {topic}..."
|
||||
def generate_draft(self):
|
||||
self.state.draft = "# AI Safety\n\nThis is a draft about AI Safety..."
|
||||
return self.state.draft
|
||||
|
||||
@listen(generate_draft)
|
||||
@human_feedback(
|
||||
message="Please review this draft. Reply 'approved', 'rejected', or provide revision feedback:",
|
||||
message="Please review this draft. Approve, reject, or describe what needs changing:",
|
||||
emit=["approved", "rejected", "needs_revision"],
|
||||
llm="gpt-4o-mini",
|
||||
default_outcome="needs_revision",
|
||||
)
|
||||
def review_draft(self, draft):
|
||||
return draft
|
||||
@listen(or_("generate_draft", "needs_revision"))
|
||||
def review_draft(self):
|
||||
self.state.revision_count += 1
|
||||
return f"{self.state.draft} (v{self.state.revision_count})"
|
||||
|
||||
@listen("approved")
|
||||
def publish_content(self, result: HumanFeedbackResult):
|
||||
self.state.final_content = result.output
|
||||
print("\n✅ Content approved and published!")
|
||||
print(f"Reviewer comment: {result.feedback}")
|
||||
self.state.status = "published"
|
||||
print(f"Content approved and published! Reviewer said: {result.feedback}")
|
||||
return "published"
|
||||
|
||||
@listen("rejected")
|
||||
def handle_rejection(self, result: HumanFeedbackResult):
|
||||
print("\n❌ Content rejected")
|
||||
print(f"Reason: {result.feedback}")
|
||||
self.state.status = "rejected"
|
||||
print(f"Content rejected. Reason: {result.feedback}")
|
||||
return "rejected"
|
||||
|
||||
@listen("needs_revision")
|
||||
def revise_content(self, result: HumanFeedbackResult):
|
||||
self.state.revision_count += 1
|
||||
print(f"\n📝 Revision #{self.state.revision_count} requested")
|
||||
print(f"Feedback: {result.feedback}")
|
||||
|
||||
# In a real flow, you might loop back to generate_draft
|
||||
# For this example, we just acknowledge
|
||||
return "revision_requested"
|
||||
|
||||
|
||||
# Run the flow
|
||||
flow = ContentApprovalFlow()
|
||||
result = flow.kickoff()
|
||||
print(f"\nFlow completed. Revisions requested: {flow.state.revision_count}")
|
||||
print(f"\nFlow completed. Status: {flow.state.status}, Reviews: {flow.state.revision_count}")
|
||||
```
|
||||
|
||||
```text Output
|
||||
What topic should I write about? AI Safety
|
||||
==================================================
|
||||
OUTPUT FOR REVIEW:
|
||||
==================================================
|
||||
# AI Safety
|
||||
|
||||
This is a draft about AI Safety... (v1)
|
||||
==================================================
|
||||
|
||||
Please review this draft. Approve, reject, or describe what needs changing:
|
||||
(Press Enter to skip, or type your feedback)
|
||||
|
||||
Your feedback: Needs more detail on alignment research
|
||||
|
||||
==================================================
|
||||
OUTPUT FOR REVIEW:
|
||||
==================================================
|
||||
# AI Safety
|
||||
|
||||
This is a draft about AI Safety...
|
||||
This is a draft about AI Safety... (v2)
|
||||
==================================================
|
||||
|
||||
Please review this draft. Reply 'approved', 'rejected', or provide revision feedback:
|
||||
Please review this draft. Approve, reject, or describe what needs changing:
|
||||
(Press Enter to skip, or type your feedback)
|
||||
|
||||
Your feedback: Looks good, approved!
|
||||
|
||||
✅ Content approved and published!
|
||||
Reviewer comment: Looks good, approved!
|
||||
Content approved and published! Reviewer said: Looks good, approved!
|
||||
|
||||
Flow completed. Revisions requested: 0
|
||||
Flow completed. Status: published, Reviews: 2
|
||||
```
|
||||
|
||||
</CodeGroup>
|
||||
|
||||
The key pattern is `@listen(or_("generate_draft", "needs_revision"))` — the review method listens to both the initial trigger and its own revision outcome, creating a self-loop that repeats until the human approves or rejects.
|
||||
|
||||
## Combining with Other Decorators
|
||||
|
||||
The `@human_feedback` decorator works with other flow decorators. Place it as the innermost decorator (closest to the function):
|
||||
The `@human_feedback` decorator works with `@start()`, `@listen()`, and `or_()`. Both decorator orderings work — the framework propagates attributes in both directions — but the recommended patterns are:
|
||||
|
||||
```python Code
|
||||
# Correct: @human_feedback is innermost (closest to the function)
|
||||
# One-shot review at the start of a flow (no self-loop)
|
||||
@start()
|
||||
@human_feedback(message="Review this:")
|
||||
@human_feedback(message="Review this:", emit=["approved", "rejected"], llm="gpt-4o-mini")
|
||||
def my_start_method(self):
|
||||
return "content"
|
||||
|
||||
# Linear review on a listener (no self-loop)
|
||||
@listen(other_method)
|
||||
@human_feedback(message="Review this too:")
|
||||
@human_feedback(message="Review this too:", emit=["good", "bad"], llm="gpt-4o-mini")
|
||||
def my_listener(self, data):
|
||||
return f"processed: {data}"
|
||||
|
||||
# Self-loop: review that can loop back for revisions
|
||||
@human_feedback(message="Approve or revise?", emit=["approved", "revise"], llm="gpt-4o-mini")
|
||||
@listen(or_("upstream_method", "revise"))
|
||||
def review_with_loop(self):
|
||||
return "content for review"
|
||||
```
|
||||
|
||||
<Tip>
|
||||
Place `@human_feedback` as the innermost decorator (last/closest to the function) so it wraps the method directly and can capture the return value before passing to the flow system.
|
||||
</Tip>
|
||||
### Self-loop pattern
|
||||
|
||||
To create a revision loop, the review method must listen to **both** an upstream trigger and its own revision outcome using `or_()`:
|
||||
|
||||
```python Code
|
||||
@start()
|
||||
def generate(self):
|
||||
return "initial draft"
|
||||
|
||||
@human_feedback(
|
||||
message="Approve or request changes?",
|
||||
emit=["revise", "approved"],
|
||||
llm="gpt-4o-mini",
|
||||
default_outcome="approved",
|
||||
)
|
||||
@listen(or_("generate", "revise"))
|
||||
def review(self):
|
||||
return "content"
|
||||
|
||||
@listen("approved")
|
||||
def publish(self):
|
||||
return "published"
|
||||
```
|
||||
|
||||
When the outcome is `"revise"`, the flow routes back to `review` (because it listens to `"revise"` via `or_()`). When the outcome is `"approved"`, the flow continues to `publish`. This works because the flow engine exempts routers from the "fire once" rule, allowing them to re-execute on each loop iteration.
|
||||
|
||||
### Chained routers
|
||||
|
||||
A listener triggered by one router's outcome can itself be a router:
|
||||
|
||||
```python Code
|
||||
@start()
|
||||
def generate(self):
|
||||
return "draft content"
|
||||
|
||||
@human_feedback(message="First review:", emit=["approved", "rejected"], llm="gpt-4o-mini")
|
||||
@listen("generate")
|
||||
def first_review(self):
|
||||
return "draft content"
|
||||
|
||||
@human_feedback(message="Final review:", emit=["publish", "hold"], llm="gpt-4o-mini")
|
||||
@listen("approved")
|
||||
def final_review(self, prev):
|
||||
return "final content"
|
||||
|
||||
@listen("publish")
|
||||
def on_publish(self, prev):
|
||||
return "published"
|
||||
|
||||
@listen("hold")
|
||||
def on_hold(self, prev):
|
||||
return "held for later"
|
||||
```
|
||||
|
||||
### Limitations
|
||||
|
||||
- **`@start()` methods run once**: A `@start()` method cannot self-loop. If you need a revision cycle, use a separate `@start()` method as the entry point and put the `@human_feedback` on a `@listen()` method.
|
||||
- **No `@start()` + `@listen()` on the same method**: This is a Flow framework constraint. A method is either a start point or a listener, not both.
|
||||
|
||||
## Best Practices
|
||||
|
||||
### 1. Write Clear Request Messages
|
||||
|
||||
The `request` parameter is what the human sees. Make it actionable:
|
||||
The `message` parameter is what the human sees. Make it actionable:
|
||||
|
||||
```python Code
|
||||
# ✅ Good - clear and actionable
|
||||
@@ -516,9 +582,9 @@ class ContentPipeline(Flow):
|
||||
@start()
|
||||
@human_feedback(
|
||||
message="Approve this content for publication?",
|
||||
emit=["approved", "rejected", "needs_revision"],
|
||||
emit=["approved", "rejected"],
|
||||
llm="gpt-4o-mini",
|
||||
default_outcome="needs_revision",
|
||||
default_outcome="rejected",
|
||||
provider=SlackNotificationProvider("#content-reviews"),
|
||||
)
|
||||
def generate_content(self):
|
||||
@@ -534,11 +600,6 @@ class ContentPipeline(Flow):
|
||||
print(f"Archived. Reason: {result.feedback}")
|
||||
return {"status": "archived"}
|
||||
|
||||
@listen("needs_revision")
|
||||
def queue_revision(self, result):
|
||||
print(f"Queued for revision: {result.feedback}")
|
||||
return {"status": "revision_needed"}
|
||||
|
||||
|
||||
# Starting the flow (will pause and wait for Slack response)
|
||||
def start_content_pipeline():
|
||||
@@ -594,22 +655,22 @@ Over time, the human sees progressively better pre-reviewed output because each
|
||||
```python Code
|
||||
class ArticleReviewFlow(Flow):
|
||||
@start()
|
||||
def generate_article(self):
|
||||
return self.crew.kickoff(inputs={"topic": "AI Safety"}).raw
|
||||
|
||||
@human_feedback(
|
||||
message="Review this article draft:",
|
||||
emit=["approved", "needs_revision"],
|
||||
llm="gpt-4o-mini",
|
||||
learn=True, # enable HITL learning
|
||||
)
|
||||
def generate_article(self):
|
||||
return self.crew.kickoff(inputs={"topic": "AI Safety"}).raw
|
||||
@listen(or_("generate_article", "needs_revision"))
|
||||
def review_article(self):
|
||||
return self.last_human_feedback.output if self.last_human_feedback else "article draft"
|
||||
|
||||
@listen("approved")
|
||||
def publish(self):
|
||||
print(f"Publishing: {self.last_human_feedback.output}")
|
||||
|
||||
@listen("needs_revision")
|
||||
def revise(self):
|
||||
print("Revising based on feedback...")
|
||||
```
|
||||
|
||||
**First run**: The human sees the raw output and says "Always include citations for factual claims." The lesson is distilled and stored in memory.
|
||||
|
||||
@@ -38,22 +38,21 @@ CrewAI Enterprise는 AI 워크플로우를 협업적인 인간-AI 프로세스
|
||||
`@human_feedback` 데코레이터를 사용하여 Flow 내에 인간 검토 체크포인트를 구성합니다. 실행이 검토 포인트에 도달하면 시스템이 일시 중지되고, 담당자에게 이메일로 알리며, 응답을 기다립니다.
|
||||
|
||||
```python
|
||||
from crewai.flow.flow import Flow, start, listen
|
||||
from crewai.flow.flow import Flow, start, listen, or_
|
||||
from crewai.flow.human_feedback import human_feedback, HumanFeedbackResult
|
||||
|
||||
class ContentApprovalFlow(Flow):
|
||||
@start()
|
||||
def generate_content(self):
|
||||
# AI가 콘텐츠 생성
|
||||
return "Q1 캠페인용 마케팅 카피 생성..."
|
||||
|
||||
@listen(generate_content)
|
||||
@human_feedback(
|
||||
message="브랜드 준수를 위해 이 콘텐츠를 검토해 주세요:",
|
||||
emit=["approved", "rejected", "needs_revision"],
|
||||
)
|
||||
def review_content(self, content):
|
||||
return content
|
||||
@listen(or_("generate_content", "needs_revision"))
|
||||
def review_content(self):
|
||||
return "검토용 마케팅 카피..."
|
||||
|
||||
@listen("approved")
|
||||
def publish_content(self, result: HumanFeedbackResult):
|
||||
@@ -62,10 +61,6 @@ class ContentApprovalFlow(Flow):
|
||||
@listen("rejected")
|
||||
def archive_content(self, result: HumanFeedbackResult):
|
||||
print(f"콘텐츠 거부됨. 사유: {result.feedback}")
|
||||
|
||||
@listen("needs_revision")
|
||||
def revise_content(self, result: HumanFeedbackResult):
|
||||
print(f"수정 요청: {result.feedback}")
|
||||
```
|
||||
|
||||
완전한 구현 세부 사항은 [Flow에서 인간 피드백](/ko/learn/human-feedback-in-flows) 가이드를 참조하세요.
|
||||
|
||||
@@ -98,33 +98,43 @@ def handle_feedback(self, result):
|
||||
`emit`을 지정하면, 데코레이터는 라우터가 됩니다. 인간의 자유 형식 피드백이 LLM에 의해 해석되어 지정된 outcome 중 하나로 매핑됩니다:
|
||||
|
||||
```python Code
|
||||
@start()
|
||||
@human_feedback(
|
||||
message="이 콘텐츠의 출판을 승인하시겠습니까?",
|
||||
emit=["approved", "rejected", "needs_revision"],
|
||||
llm="gpt-4o-mini",
|
||||
default_outcome="needs_revision",
|
||||
)
|
||||
def review_content(self):
|
||||
return "블로그 게시물 초안 내용..."
|
||||
from crewai.flow.flow import Flow, start, listen, or_
|
||||
from crewai.flow.human_feedback import human_feedback
|
||||
|
||||
@listen("approved")
|
||||
def publish(self, result):
|
||||
print(f"출판 중! 사용자 의견: {result.feedback}")
|
||||
class ReviewFlow(Flow):
|
||||
@start()
|
||||
def generate_content(self):
|
||||
return "블로그 게시물 초안 내용..."
|
||||
|
||||
@listen("rejected")
|
||||
def discard(self, result):
|
||||
print(f"폐기됨. 이유: {result.feedback}")
|
||||
@human_feedback(
|
||||
message="이 콘텐츠의 출판을 승인하시겠습니까?",
|
||||
emit=["approved", "rejected", "needs_revision"],
|
||||
llm="gpt-4o-mini",
|
||||
default_outcome="needs_revision",
|
||||
)
|
||||
@listen(or_("generate_content", "needs_revision"))
|
||||
def review_content(self):
|
||||
return "블로그 게시물 초안 내용..."
|
||||
|
||||
@listen("needs_revision")
|
||||
def revise(self, result):
|
||||
print(f"다음을 기반으로 수정 중: {result.feedback}")
|
||||
@listen("approved")
|
||||
def publish(self, result):
|
||||
print(f"출판 중! 사용자 의견: {result.feedback}")
|
||||
|
||||
@listen("rejected")
|
||||
def discard(self, result):
|
||||
print(f"폐기됨. 이유: {result.feedback}")
|
||||
```
|
||||
|
||||
사용자가 "더 자세한 내용이 필요합니다"와 같이 말하면, LLM이 이를 `"needs_revision"`으로 매핑하고, `or_()`를 통해 `review_content`가 다시 트리거됩니다 — 수정 루프가 생성됩니다. outcome이 `"approved"` 또는 `"rejected"`가 될 때까지 루프가 계속됩니다.
|
||||
|
||||
<Tip>
|
||||
LLM은 가능한 경우 구조화된 출력(function calling)을 사용하여 응답이 지정된 outcome 중 하나임을 보장합니다. 이로 인해 라우팅이 신뢰할 수 있고 예측 가능해집니다.
|
||||
</Tip>
|
||||
|
||||
<Warning>
|
||||
`@start()` 메서드는 flow 시작 시 한 번만 실행됩니다. 수정 루프가 필요한 경우, start 메서드를 review 메서드와 분리하고 review 메서드에 `@listen(or_("trigger", "revision_outcome"))`를 사용하여 self-loop을 활성화하세요.
|
||||
</Warning>
|
||||
|
||||
## HumanFeedbackResult
|
||||
|
||||
`HumanFeedbackResult` 데이터클래스는 인간 피드백 상호작용에 대한 모든 정보를 포함합니다:
|
||||
@@ -193,116 +203,162 @@ def summarize(self):
|
||||
<CodeGroup>
|
||||
|
||||
```python Code
|
||||
from crewai.flow.flow import Flow, start, listen
|
||||
from crewai.flow.flow import Flow, start, listen, or_
|
||||
from crewai.flow.human_feedback import human_feedback, HumanFeedbackResult
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class ContentState(BaseModel):
|
||||
topic: str = ""
|
||||
draft: str = ""
|
||||
final_content: str = ""
|
||||
revision_count: int = 0
|
||||
status: str = "pending"
|
||||
|
||||
|
||||
class ContentApprovalFlow(Flow[ContentState]):
|
||||
"""콘텐츠를 생성하고 인간의 승인을 받는 Flow입니다."""
|
||||
"""콘텐츠를 생성하고 승인될 때까지 반복하는 Flow."""
|
||||
|
||||
@start()
|
||||
def get_topic(self):
|
||||
self.state.topic = input("어떤 주제에 대해 글을 쓸까요? ")
|
||||
return self.state.topic
|
||||
|
||||
@listen(get_topic)
|
||||
def generate_draft(self, topic):
|
||||
# 실제 사용에서는 LLM을 호출합니다
|
||||
self.state.draft = f"# {topic}\n\n{topic}에 대한 초안입니다..."
|
||||
def generate_draft(self):
|
||||
self.state.draft = "# AI 안전\n\nAI 안전에 대한 초안..."
|
||||
return self.state.draft
|
||||
|
||||
@listen(generate_draft)
|
||||
@human_feedback(
|
||||
message="이 초안을 검토해 주세요. 'approved', 'rejected'로 답하거나 수정 피드백을 제공해 주세요:",
|
||||
message="이 초안을 검토해 주세요. 승인, 거부 또는 변경이 필요한 사항을 설명해 주세요:",
|
||||
emit=["approved", "rejected", "needs_revision"],
|
||||
llm="gpt-4o-mini",
|
||||
default_outcome="needs_revision",
|
||||
)
|
||||
def review_draft(self, draft):
|
||||
return draft
|
||||
@listen(or_("generate_draft", "needs_revision"))
|
||||
def review_draft(self):
|
||||
self.state.revision_count += 1
|
||||
return f"{self.state.draft} (v{self.state.revision_count})"
|
||||
|
||||
@listen("approved")
|
||||
def publish_content(self, result: HumanFeedbackResult):
|
||||
self.state.final_content = result.output
|
||||
print("\n✅ 콘텐츠가 승인되어 출판되었습니다!")
|
||||
print(f"검토자 코멘트: {result.feedback}")
|
||||
self.state.status = "published"
|
||||
print(f"콘텐츠 승인 및 게시! 리뷰어 의견: {result.feedback}")
|
||||
return "published"
|
||||
|
||||
@listen("rejected")
|
||||
def handle_rejection(self, result: HumanFeedbackResult):
|
||||
print("\n❌ 콘텐츠가 거부되었습니다")
|
||||
print(f"이유: {result.feedback}")
|
||||
self.state.status = "rejected"
|
||||
print(f"콘텐츠 거부됨. 이유: {result.feedback}")
|
||||
return "rejected"
|
||||
|
||||
@listen("needs_revision")
|
||||
def revise_content(self, result: HumanFeedbackResult):
|
||||
self.state.revision_count += 1
|
||||
print(f"\n📝 수정 #{self.state.revision_count} 요청됨")
|
||||
print(f"피드백: {result.feedback}")
|
||||
|
||||
# 실제 Flow에서는 generate_draft로 돌아갈 수 있습니다
|
||||
# 이 예제에서는 단순히 확인합니다
|
||||
return "revision_requested"
|
||||
|
||||
|
||||
# Flow 실행
|
||||
flow = ContentApprovalFlow()
|
||||
result = flow.kickoff()
|
||||
print(f"\nFlow 완료. 요청된 수정: {flow.state.revision_count}")
|
||||
print(f"\nFlow 완료. 상태: {flow.state.status}, 검토 횟수: {flow.state.revision_count}")
|
||||
```
|
||||
|
||||
```text Output
|
||||
어떤 주제에 대해 글을 쓸까요? AI 안전
|
||||
==================================================
|
||||
OUTPUT FOR REVIEW:
|
||||
==================================================
|
||||
# AI 안전
|
||||
|
||||
AI 안전에 대한 초안... (v1)
|
||||
==================================================
|
||||
|
||||
이 초안을 검토해 주세요. 승인, 거부 또는 변경이 필요한 사항을 설명해 주세요:
|
||||
(Press Enter to skip, or type your feedback)
|
||||
|
||||
Your feedback: 더 자세한 내용이 필요합니다
|
||||
|
||||
==================================================
|
||||
OUTPUT FOR REVIEW:
|
||||
==================================================
|
||||
# AI 안전
|
||||
|
||||
AI 안전에 대한 초안입니다...
|
||||
AI 안전에 대한 초안... (v2)
|
||||
==================================================
|
||||
|
||||
이 초안을 검토해 주세요. 'approved', 'rejected'로 답하거나 수정 피드백을 제공해 주세요:
|
||||
이 초안을 검토해 주세요. 승인, 거부 또는 변경이 필요한 사항을 설명해 주세요:
|
||||
(Press Enter to skip, or type your feedback)
|
||||
|
||||
Your feedback: 좋아 보입니다, 승인!
|
||||
|
||||
✅ 콘텐츠가 승인되어 출판되었습니다!
|
||||
검토자 코멘트: 좋아 보입니다, 승인!
|
||||
콘텐츠 승인 및 게시! 리뷰어 의견: 좋아 보입니다, 승인!
|
||||
|
||||
Flow 완료. 요청된 수정: 0
|
||||
Flow 완료. 상태: published, 검토 횟수: 2
|
||||
```
|
||||
|
||||
</CodeGroup>
|
||||
|
||||
## 다른 데코레이터와 결합하기
|
||||
|
||||
`@human_feedback` 데코레이터는 다른 Flow 데코레이터와 함께 작동합니다. 가장 안쪽 데코레이터(함수에 가장 가까운)로 배치하세요:
|
||||
`@human_feedback` 데코레이터는 `@start()`, `@listen()`, `or_()`와 함께 작동합니다. 데코레이터 순서는 두 가지 모두 동작합니다—프레임워크가 양방향으로 속성을 전파합니다—하지만 권장 패턴은 다음과 같습니다:
|
||||
|
||||
```python Code
|
||||
# 올바름: @human_feedback이 가장 안쪽(함수에 가장 가까움)
|
||||
# Flow 시작 시 일회성 검토 (self-loop 없음)
|
||||
@start()
|
||||
@human_feedback(message="이것을 검토해 주세요:")
|
||||
@human_feedback(message="이것을 검토해 주세요:", emit=["approved", "rejected"], llm="gpt-4o-mini")
|
||||
def my_start_method(self):
|
||||
return "content"
|
||||
|
||||
# 리스너에서 선형 검토 (self-loop 없음)
|
||||
@listen(other_method)
|
||||
@human_feedback(message="이것도 검토해 주세요:")
|
||||
@human_feedback(message="이것도 검토해 주세요:", emit=["good", "bad"], llm="gpt-4o-mini")
|
||||
def my_listener(self, data):
|
||||
return f"processed: {data}"
|
||||
|
||||
# Self-loop: 수정을 위해 반복할 수 있는 검토
|
||||
@human_feedback(message="승인 또는 수정 요청?", emit=["approved", "revise"], llm="gpt-4o-mini")
|
||||
@listen(or_("upstream_method", "revise"))
|
||||
def review_with_loop(self):
|
||||
return "content for review"
|
||||
```
|
||||
|
||||
<Tip>
|
||||
`@human_feedback`를 가장 안쪽 데코레이터(마지막/함수에 가장 가까움)로 배치하여 메서드를 직접 래핑하고 Flow 시스템에 전달하기 전에 반환 값을 캡처할 수 있도록 하세요.
|
||||
</Tip>
|
||||
### Self-loop 패턴
|
||||
|
||||
수정 루프를 만들려면 `or_()`를 사용하여 검토 메서드가 **상위 트리거**와 **자체 수정 outcome**을 모두 리스닝해야 합니다:
|
||||
|
||||
```python Code
|
||||
@start()
|
||||
def generate(self):
|
||||
return "initial draft"
|
||||
|
||||
@human_feedback(
|
||||
message="승인하시겠습니까, 아니면 변경을 요청하시겠습니까?",
|
||||
emit=["revise", "approved"],
|
||||
llm="gpt-4o-mini",
|
||||
default_outcome="approved",
|
||||
)
|
||||
@listen(or_("generate", "revise"))
|
||||
def review(self):
|
||||
return "content"
|
||||
|
||||
@listen("approved")
|
||||
def publish(self):
|
||||
return "published"
|
||||
```
|
||||
|
||||
outcome이 `"revise"`이면 flow가 `review`로 다시 라우팅됩니다 (`or_()`를 통해 `"revise"`를 리스닝하기 때문). outcome이 `"approved"`이면 flow가 `publish`로 계속됩니다. flow 엔진이 라우터를 "한 번만 실행" 규칙에서 제외하여 각 루프 반복마다 재실행할 수 있기 때문에 이 패턴이 동작합니다.
|
||||
|
||||
### 체인된 라우터
|
||||
|
||||
한 라우터의 outcome으로 트리거된 리스너가 그 자체로 라우터가 될 수 있습니다:
|
||||
|
||||
```python Code
|
||||
@start()
|
||||
@human_feedback(message="첫 번째 검토:", emit=["approved", "rejected"], llm="gpt-4o-mini")
|
||||
def draft(self):
|
||||
return "draft content"
|
||||
|
||||
@listen("approved")
|
||||
@human_feedback(message="최종 검토:", emit=["publish", "revise"], llm="gpt-4o-mini")
|
||||
def final_review(self, prev):
|
||||
return "final content"
|
||||
|
||||
@listen("publish")
|
||||
def on_publish(self, prev):
|
||||
return "published"
|
||||
```
|
||||
|
||||
### 제한 사항
|
||||
|
||||
- **`@start()` 메서드는 한 번만 실행**: `@start()` 메서드는 self-loop할 수 없습니다. 수정 주기가 필요하면 별도의 `@start()` 메서드를 진입점으로 사용하고 `@listen()` 메서드에 `@human_feedback`를 배치하세요.
|
||||
- **동일 메서드에 `@start()` + `@listen()` 불가**: 이는 Flow 프레임워크 제약입니다. 메서드는 시작점이거나 리스너여야 하며, 둘 다일 수 없습니다.
|
||||
|
||||
## 모범 사례
|
||||
|
||||
@@ -516,9 +572,9 @@ class ContentPipeline(Flow):
|
||||
@start()
|
||||
@human_feedback(
|
||||
message="이 콘텐츠의 출판을 승인하시겠습니까?",
|
||||
emit=["approved", "rejected", "needs_revision"],
|
||||
emit=["approved", "rejected"],
|
||||
llm="gpt-4o-mini",
|
||||
default_outcome="needs_revision",
|
||||
default_outcome="rejected",
|
||||
provider=SlackNotificationProvider("#content-reviews"),
|
||||
)
|
||||
def generate_content(self):
|
||||
@@ -534,11 +590,6 @@ class ContentPipeline(Flow):
|
||||
print(f"보관됨. 이유: {result.feedback}")
|
||||
return {"status": "archived"}
|
||||
|
||||
@listen("needs_revision")
|
||||
def queue_revision(self, result):
|
||||
print(f"수정 대기열에 추가됨: {result.feedback}")
|
||||
return {"status": "revision_needed"}
|
||||
|
||||
|
||||
# Flow 시작 (Slack 응답을 기다리며 일시 중지)
|
||||
def start_content_pipeline():
|
||||
@@ -594,22 +645,22 @@ async def on_slack_feedback_async(flow_id: str, slack_message: str):
|
||||
```python Code
|
||||
class ArticleReviewFlow(Flow):
|
||||
@start()
|
||||
@human_feedback(
|
||||
message="Review this article draft:",
|
||||
emit=["approved", "needs_revision"],
|
||||
llm="gpt-4o-mini",
|
||||
learn=True, # HITL 학습 활성화
|
||||
)
|
||||
def generate_article(self):
|
||||
return self.crew.kickoff(inputs={"topic": "AI Safety"}).raw
|
||||
|
||||
@human_feedback(
|
||||
message="이 글 초안을 검토해 주세요:",
|
||||
emit=["approved", "needs_revision"],
|
||||
llm="gpt-4o-mini",
|
||||
learn=True,
|
||||
)
|
||||
@listen(or_("generate_article", "needs_revision"))
|
||||
def review_article(self):
|
||||
return self.last_human_feedback.output if self.last_human_feedback else "article draft"
|
||||
|
||||
@listen("approved")
|
||||
def publish(self):
|
||||
print(f"Publishing: {self.last_human_feedback.output}")
|
||||
|
||||
@listen("needs_revision")
|
||||
def revise(self):
|
||||
print("Revising based on feedback...")
|
||||
```
|
||||
|
||||
**첫 번째 실행**: 인간이 원시 출력을 보고 "사실에 대한 주장에는 항상 인용을 포함하세요."라고 말합니다. 교훈이 추출되어 메모리에 저장됩니다.
|
||||
|
||||
@@ -38,22 +38,21 @@ O CrewAI Enterprise oferece um sistema abrangente de gerenciamento Human-in-the-
|
||||
Configure checkpoints de revisão humana em seus Flows usando o decorador `@human_feedback`. Quando a execução atinge um ponto de revisão, o sistema pausa, notifica o responsável via email e aguarda uma resposta.
|
||||
|
||||
```python
|
||||
from crewai.flow.flow import Flow, start, listen
|
||||
from crewai.flow.flow import Flow, start, listen, or_
|
||||
from crewai.flow.human_feedback import human_feedback, HumanFeedbackResult
|
||||
|
||||
class ContentApprovalFlow(Flow):
|
||||
@start()
|
||||
def generate_content(self):
|
||||
# IA gera conteúdo
|
||||
return "Texto de marketing gerado para campanha Q1..."
|
||||
|
||||
@listen(generate_content)
|
||||
@human_feedback(
|
||||
message="Por favor, revise este conteúdo para conformidade com a marca:",
|
||||
emit=["approved", "rejected", "needs_revision"],
|
||||
)
|
||||
def review_content(self, content):
|
||||
return content
|
||||
@listen(or_("generate_content", "needs_revision"))
|
||||
def review_content(self):
|
||||
return "Texto de marketing para revisão..."
|
||||
|
||||
@listen("approved")
|
||||
def publish_content(self, result: HumanFeedbackResult):
|
||||
@@ -62,10 +61,6 @@ class ContentApprovalFlow(Flow):
|
||||
@listen("rejected")
|
||||
def archive_content(self, result: HumanFeedbackResult):
|
||||
print(f"Conteúdo rejeitado. Motivo: {result.feedback}")
|
||||
|
||||
@listen("needs_revision")
|
||||
def revise_content(self, result: HumanFeedbackResult):
|
||||
print(f"Revisão solicitada: {result.feedback}")
|
||||
```
|
||||
|
||||
Para detalhes completos de implementação, consulte o guia [Feedback Humano em Flows](/pt-BR/learn/human-feedback-in-flows).
|
||||
|
||||
@@ -98,33 +98,43 @@ def handle_feedback(self, result):
|
||||
Quando você especifica `emit`, o decorador se torna um roteador. O feedback livre do humano é interpretado por um LLM e mapeado para um dos outcomes especificados:
|
||||
|
||||
```python Code
|
||||
@start()
|
||||
@human_feedback(
|
||||
message="Você aprova este conteúdo para publicação?",
|
||||
emit=["approved", "rejected", "needs_revision"],
|
||||
llm="gpt-4o-mini",
|
||||
default_outcome="needs_revision",
|
||||
)
|
||||
def review_content(self):
|
||||
return "Rascunho do post do blog aqui..."
|
||||
from crewai.flow.flow import Flow, start, listen, or_
|
||||
from crewai.flow.human_feedback import human_feedback
|
||||
|
||||
@listen("approved")
|
||||
def publish(self, result):
|
||||
print(f"Publicando! Usuário disse: {result.feedback}")
|
||||
class ReviewFlow(Flow):
|
||||
@start()
|
||||
def generate_content(self):
|
||||
return "Rascunho do post do blog aqui..."
|
||||
|
||||
@listen("rejected")
|
||||
def discard(self, result):
|
||||
print(f"Descartando. Motivo: {result.feedback}")
|
||||
@human_feedback(
|
||||
message="Você aprova este conteúdo para publicação?",
|
||||
emit=["approved", "rejected", "needs_revision"],
|
||||
llm="gpt-4o-mini",
|
||||
default_outcome="needs_revision",
|
||||
)
|
||||
@listen(or_("generate_content", "needs_revision"))
|
||||
def review_content(self):
|
||||
return "Rascunho do post do blog aqui..."
|
||||
|
||||
@listen("needs_revision")
|
||||
def revise(self, result):
|
||||
print(f"Revisando baseado em: {result.feedback}")
|
||||
@listen("approved")
|
||||
def publish(self, result):
|
||||
print(f"Publicando! Usuário disse: {result.feedback}")
|
||||
|
||||
@listen("rejected")
|
||||
def discard(self, result):
|
||||
print(f"Descartando. Motivo: {result.feedback}")
|
||||
```
|
||||
|
||||
Quando o humano diz algo como "precisa de mais detalhes", o LLM mapeia para `"needs_revision"`, que dispara `review_content` novamente via `or_()` — criando um loop de revisão. O loop continua até que o outcome seja `"approved"` ou `"rejected"`.
|
||||
|
||||
<Tip>
|
||||
O LLM usa saídas estruturadas (function calling) quando disponível para garantir que a resposta seja um dos seus outcomes especificados. Isso torna o roteamento confiável e previsível.
|
||||
</Tip>
|
||||
|
||||
<Warning>
|
||||
Um método `@start()` só executa uma vez no início do flow. Se você precisa de um loop de revisão, separe o método start do método de revisão e use `@listen(or_("trigger", "revision_outcome"))` no método de revisão para habilitar o self-loop.
|
||||
</Warning>
|
||||
|
||||
## HumanFeedbackResult
|
||||
|
||||
O dataclass `HumanFeedbackResult` contém todas as informações sobre uma interação de feedback humano:
|
||||
@@ -193,116 +203,162 @@ Aqui está um exemplo completo implementando um fluxo de revisão e aprovação
|
||||
<CodeGroup>
|
||||
|
||||
```python Code
|
||||
from crewai.flow.flow import Flow, start, listen
|
||||
from crewai.flow.flow import Flow, start, listen, or_
|
||||
from crewai.flow.human_feedback import human_feedback, HumanFeedbackResult
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class ContentState(BaseModel):
|
||||
topic: str = ""
|
||||
draft: str = ""
|
||||
final_content: str = ""
|
||||
revision_count: int = 0
|
||||
status: str = "pending"
|
||||
|
||||
|
||||
class ContentApprovalFlow(Flow[ContentState]):
|
||||
"""Um flow que gera conteúdo e obtém aprovação humana."""
|
||||
"""Um flow que gera conteúdo e faz loop até o humano aprovar."""
|
||||
|
||||
@start()
|
||||
def get_topic(self):
|
||||
self.state.topic = input("Sobre qual tópico devo escrever? ")
|
||||
return self.state.topic
|
||||
|
||||
@listen(get_topic)
|
||||
def generate_draft(self, topic):
|
||||
# Em uso real, isso chamaria um LLM
|
||||
self.state.draft = f"# {topic}\n\nEste é um rascunho sobre {topic}..."
|
||||
def generate_draft(self):
|
||||
self.state.draft = "# IA Segura\n\nEste é um rascunho sobre IA Segura..."
|
||||
return self.state.draft
|
||||
|
||||
@listen(generate_draft)
|
||||
@human_feedback(
|
||||
message="Por favor, revise este rascunho. Responda 'approved', 'rejected', ou forneça feedback de revisão:",
|
||||
message="Por favor, revise este rascunho. Aprove, rejeite ou descreva o que precisa mudar:",
|
||||
emit=["approved", "rejected", "needs_revision"],
|
||||
llm="gpt-4o-mini",
|
||||
default_outcome="needs_revision",
|
||||
)
|
||||
def review_draft(self, draft):
|
||||
return draft
|
||||
@listen(or_("generate_draft", "needs_revision"))
|
||||
def review_draft(self):
|
||||
self.state.revision_count += 1
|
||||
return f"{self.state.draft} (v{self.state.revision_count})"
|
||||
|
||||
@listen("approved")
|
||||
def publish_content(self, result: HumanFeedbackResult):
|
||||
self.state.final_content = result.output
|
||||
print("\n✅ Conteúdo aprovado e publicado!")
|
||||
print(f"Comentário do revisor: {result.feedback}")
|
||||
self.state.status = "published"
|
||||
print(f"Conteúdo aprovado e publicado! Revisor disse: {result.feedback}")
|
||||
return "published"
|
||||
|
||||
@listen("rejected")
|
||||
def handle_rejection(self, result: HumanFeedbackResult):
|
||||
print("\n❌ Conteúdo rejeitado")
|
||||
print(f"Motivo: {result.feedback}")
|
||||
self.state.status = "rejected"
|
||||
print(f"Conteúdo rejeitado. Motivo: {result.feedback}")
|
||||
return "rejected"
|
||||
|
||||
@listen("needs_revision")
|
||||
def revise_content(self, result: HumanFeedbackResult):
|
||||
self.state.revision_count += 1
|
||||
print(f"\n📝 Revisão #{self.state.revision_count} solicitada")
|
||||
print(f"Feedback: {result.feedback}")
|
||||
|
||||
# Em um flow real, você pode voltar para generate_draft
|
||||
# Para este exemplo, apenas reconhecemos
|
||||
return "revision_requested"
|
||||
|
||||
|
||||
# Executar o flow
|
||||
flow = ContentApprovalFlow()
|
||||
result = flow.kickoff()
|
||||
print(f"\nFlow concluído. Revisões solicitadas: {flow.state.revision_count}")
|
||||
print(f"\nFlow finalizado. Status: {flow.state.status}, Revisões: {flow.state.revision_count}")
|
||||
```
|
||||
|
||||
```text Output
|
||||
Sobre qual tópico devo escrever? Segurança em IA
|
||||
==================================================
|
||||
OUTPUT FOR REVIEW:
|
||||
==================================================
|
||||
# IA Segura
|
||||
|
||||
Este é um rascunho sobre IA Segura... (v1)
|
||||
==================================================
|
||||
|
||||
Por favor, revise este rascunho. Aprove, rejeite ou descreva o que precisa mudar:
|
||||
(Press Enter to skip, or type your feedback)
|
||||
|
||||
Your feedback: Preciso de mais detalhes sobre segurança em IA.
|
||||
|
||||
==================================================
|
||||
OUTPUT FOR REVIEW:
|
||||
==================================================
|
||||
# Segurança em IA
|
||||
# IA Segura
|
||||
|
||||
Este é um rascunho sobre Segurança em IA...
|
||||
Este é um rascunho sobre IA Segura... (v2)
|
||||
==================================================
|
||||
|
||||
Por favor, revise este rascunho. Responda 'approved', 'rejected', ou forneça feedback de revisão:
|
||||
Por favor, revise este rascunho. Aprove, rejeite ou descreva o que precisa mudar:
|
||||
(Press Enter to skip, or type your feedback)
|
||||
|
||||
Your feedback: Parece bom, aprovado!
|
||||
|
||||
✅ Conteúdo aprovado e publicado!
|
||||
Comentário do revisor: Parece bom, aprovado!
|
||||
Conteúdo aprovado e publicado! Revisor disse: Parece bom, aprovado!
|
||||
|
||||
Flow concluído. Revisões solicitadas: 0
|
||||
Flow finalizado. Status: published, Revisões: 2
|
||||
```
|
||||
|
||||
</CodeGroup>
|
||||
|
||||
## Combinando com Outros Decoradores
|
||||
|
||||
O decorador `@human_feedback` funciona com outros decoradores de flow. Coloque-o como o decorador mais interno (mais próximo da função):
|
||||
O decorador `@human_feedback` funciona com `@start()`, `@listen()` e `or_()`. Ambas as ordens de decoradores funcionam — o framework propaga atributos em ambas as direções — mas os padrões recomendados são:
|
||||
|
||||
```python Code
|
||||
# Correto: @human_feedback é o mais interno (mais próximo da função)
|
||||
# Revisão única no início do flow (sem self-loop)
|
||||
@start()
|
||||
@human_feedback(message="Revise isto:")
|
||||
@human_feedback(message="Revise isto:", emit=["approved", "rejected"], llm="gpt-4o-mini")
|
||||
def my_start_method(self):
|
||||
return "content"
|
||||
|
||||
# Revisão linear em um listener (sem self-loop)
|
||||
@listen(other_method)
|
||||
@human_feedback(message="Revise isto também:")
|
||||
@human_feedback(message="Revise isto também:", emit=["good", "bad"], llm="gpt-4o-mini")
|
||||
def my_listener(self, data):
|
||||
return f"processed: {data}"
|
||||
|
||||
# Self-loop: revisão que pode voltar para revisões
|
||||
@human_feedback(message="Aprovar ou revisar?", emit=["approved", "revise"], llm="gpt-4o-mini")
|
||||
@listen(or_("upstream_method", "revise"))
|
||||
def review_with_loop(self):
|
||||
return "content for review"
|
||||
```
|
||||
|
||||
<Tip>
|
||||
Coloque `@human_feedback` como o decorador mais interno (último/mais próximo da função) para que ele envolva o método diretamente e possa capturar o valor de retorno antes de passar para o sistema de flow.
|
||||
</Tip>
|
||||
### Padrão de self-loop
|
||||
|
||||
Para criar um loop de revisão, o método de revisão deve escutar **ambos** um gatilho upstream e seu próprio outcome de revisão usando `or_()`:
|
||||
|
||||
```python Code
|
||||
@start()
|
||||
def generate(self):
|
||||
return "initial draft"
|
||||
|
||||
@human_feedback(
|
||||
message="Aprovar ou solicitar alterações?",
|
||||
emit=["revise", "approved"],
|
||||
llm="gpt-4o-mini",
|
||||
default_outcome="approved",
|
||||
)
|
||||
@listen(or_("generate", "revise"))
|
||||
def review(self):
|
||||
return "content"
|
||||
|
||||
@listen("approved")
|
||||
def publish(self):
|
||||
return "published"
|
||||
```
|
||||
|
||||
Quando o outcome é `"revise"`, o flow roteia de volta para `review` (porque ele escuta `"revise"` via `or_()`). Quando o outcome é `"approved"`, o flow continua para `publish`. Isso funciona porque o engine de flow isenta roteadores da regra "fire once", permitindo que eles re-executem em cada iteração do loop.
|
||||
|
||||
### Roteadores encadeados
|
||||
|
||||
Um listener disparado pelo outcome de um roteador pode ser ele mesmo um roteador:
|
||||
|
||||
```python Code
|
||||
@start()
|
||||
@human_feedback(message="Primeira revisão:", emit=["approved", "rejected"], llm="gpt-4o-mini")
|
||||
def draft(self):
|
||||
return "draft content"
|
||||
|
||||
@listen("approved")
|
||||
@human_feedback(message="Revisão final:", emit=["publish", "revise"], llm="gpt-4o-mini")
|
||||
def final_review(self, prev):
|
||||
return "final content"
|
||||
|
||||
@listen("publish")
|
||||
def on_publish(self, prev):
|
||||
return "published"
|
||||
```
|
||||
|
||||
### Limitações
|
||||
|
||||
- **Métodos `@start()` executam uma vez**: Um método `@start()` não pode fazer self-loop. Se você precisa de um ciclo de revisão, use um método `@start()` separado como ponto de entrada e coloque o `@human_feedback` em um método `@listen()`.
|
||||
- **Sem `@start()` + `@listen()` no mesmo método**: Esta é uma restrição do framework de Flow. Um método é ou um ponto de início ou um listener, não ambos.
|
||||
|
||||
## Melhores Práticas
|
||||
|
||||
@@ -516,9 +572,9 @@ class ContentPipeline(Flow):
|
||||
@start()
|
||||
@human_feedback(
|
||||
message="Aprova este conteúdo para publicação?",
|
||||
emit=["approved", "rejected", "needs_revision"],
|
||||
emit=["approved", "rejected"],
|
||||
llm="gpt-4o-mini",
|
||||
default_outcome="needs_revision",
|
||||
default_outcome="rejected",
|
||||
provider=SlackNotificationProvider("#content-reviews"),
|
||||
)
|
||||
def generate_content(self):
|
||||
@@ -534,11 +590,6 @@ class ContentPipeline(Flow):
|
||||
print(f"Arquivado. Motivo: {result.feedback}")
|
||||
return {"status": "archived"}
|
||||
|
||||
@listen("needs_revision")
|
||||
def queue_revision(self, result):
|
||||
print(f"Na fila para revisão: {result.feedback}")
|
||||
return {"status": "revision_needed"}
|
||||
|
||||
|
||||
# Iniciando o flow (vai pausar e aguardar resposta do Slack)
|
||||
def start_content_pipeline():
|
||||
@@ -594,22 +645,22 @@ Com o tempo, o humano vê saídas pré-revisadas progressivamente melhores porqu
|
||||
```python Code
|
||||
class ArticleReviewFlow(Flow):
|
||||
@start()
|
||||
def generate_article(self):
|
||||
return self.crew.kickoff(inputs={"topic": "AI Safety"}).raw
|
||||
|
||||
@human_feedback(
|
||||
message="Review this article draft:",
|
||||
message="Revise este rascunho do artigo:",
|
||||
emit=["approved", "needs_revision"],
|
||||
llm="gpt-4o-mini",
|
||||
learn=True, # enable HITL learning
|
||||
)
|
||||
def generate_article(self):
|
||||
return self.crew.kickoff(inputs={"topic": "AI Safety"}).raw
|
||||
@listen(or_("generate_article", "needs_revision"))
|
||||
def review_article(self):
|
||||
return self.last_human_feedback.output if self.last_human_feedback else "article draft"
|
||||
|
||||
@listen("approved")
|
||||
def publish(self):
|
||||
print(f"Publishing: {self.last_human_feedback.output}")
|
||||
|
||||
@listen("needs_revision")
|
||||
def revise(self):
|
||||
print("Revising based on feedback...")
|
||||
```
|
||||
|
||||
**Primeira execução**: O humano vê a saída bruta e diz "Sempre inclua citações para afirmações factuais." A lição é destilada e armazenada na memória.
|
||||
|
||||
@@ -7,6 +7,7 @@ and memory management.
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Callable
|
||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||
import logging
|
||||
from typing import TYPE_CHECKING, Any, Literal, cast
|
||||
|
||||
@@ -685,30 +686,138 @@ class CrewAgentExecutor(CrewAgentExecutorMixin):
|
||||
Returns:
|
||||
AgentFinish if tool has result_as_answer=True, None otherwise.
|
||||
"""
|
||||
from datetime import datetime
|
||||
import json
|
||||
|
||||
from crewai.events import crewai_event_bus
|
||||
from crewai.events.types.tool_usage_events import (
|
||||
ToolUsageErrorEvent,
|
||||
ToolUsageFinishedEvent,
|
||||
ToolUsageStartedEvent,
|
||||
)
|
||||
|
||||
if not tool_calls:
|
||||
return None
|
||||
|
||||
# Only process the FIRST tool call for sequential execution with reflection
|
||||
tool_call = tool_calls[0]
|
||||
parsed_calls = [
|
||||
parsed
|
||||
for tool_call in tool_calls
|
||||
if (parsed := self._parse_native_tool_call(tool_call)) is not None
|
||||
]
|
||||
if not parsed_calls:
|
||||
return None
|
||||
|
||||
# Extract tool call info - handle OpenAI-style, Anthropic-style, and Gemini-style
|
||||
original_tools_by_name: dict[str, Any] = {}
|
||||
for tool in self.original_tools or []:
|
||||
original_tools_by_name[sanitize_tool_name(tool.name)] = tool
|
||||
|
||||
if len(parsed_calls) > 1:
|
||||
has_result_as_answer_in_batch = any(
|
||||
bool(
|
||||
original_tools_by_name.get(func_name)
|
||||
and getattr(
|
||||
original_tools_by_name.get(func_name), "result_as_answer", False
|
||||
)
|
||||
)
|
||||
for _, func_name, _ in parsed_calls
|
||||
)
|
||||
has_max_usage_count_in_batch = any(
|
||||
bool(
|
||||
original_tools_by_name.get(func_name)
|
||||
and getattr(
|
||||
original_tools_by_name.get(func_name),
|
||||
"max_usage_count",
|
||||
None,
|
||||
)
|
||||
is not None
|
||||
)
|
||||
for _, func_name, _ in parsed_calls
|
||||
)
|
||||
|
||||
# Preserve historical sequential behavior for result_as_answer batches.
|
||||
# Also avoid threading around usage counters for max_usage_count tools.
|
||||
if has_result_as_answer_in_batch or has_max_usage_count_in_batch:
|
||||
logger.debug(
|
||||
"Skipping parallel native execution because batch includes result_as_answer or max_usage_count tool"
|
||||
)
|
||||
else:
|
||||
execution_plan: list[
|
||||
tuple[str, str, str | dict[str, Any], Any | None]
|
||||
] = []
|
||||
for call_id, func_name, func_args in parsed_calls:
|
||||
original_tool = original_tools_by_name.get(func_name)
|
||||
execution_plan.append((call_id, func_name, func_args, original_tool))
|
||||
|
||||
self._append_assistant_tool_calls_message(
|
||||
[
|
||||
(call_id, func_name, func_args)
|
||||
for call_id, func_name, func_args, _ in execution_plan
|
||||
]
|
||||
)
|
||||
|
||||
max_workers = min(8, len(execution_plan))
|
||||
ordered_results: list[dict[str, Any] | None] = [None] * len(execution_plan)
|
||||
with ThreadPoolExecutor(max_workers=max_workers) as pool:
|
||||
futures = {
|
||||
pool.submit(
|
||||
self._execute_single_native_tool_call,
|
||||
call_id=call_id,
|
||||
func_name=func_name,
|
||||
func_args=func_args,
|
||||
available_functions=available_functions,
|
||||
original_tool=original_tool,
|
||||
should_execute=True,
|
||||
): idx
|
||||
for idx, (
|
||||
call_id,
|
||||
func_name,
|
||||
func_args,
|
||||
original_tool,
|
||||
) in enumerate(execution_plan)
|
||||
}
|
||||
for future in as_completed(futures):
|
||||
idx = futures[future]
|
||||
ordered_results[idx] = future.result()
|
||||
|
||||
for execution_result in ordered_results:
|
||||
if not execution_result:
|
||||
continue
|
||||
tool_finish = self._append_tool_result_and_check_finality(
|
||||
execution_result
|
||||
)
|
||||
if tool_finish:
|
||||
return tool_finish
|
||||
|
||||
reasoning_prompt = self._i18n.slice("post_tool_reasoning")
|
||||
reasoning_message: LLMMessage = {
|
||||
"role": "user",
|
||||
"content": reasoning_prompt,
|
||||
}
|
||||
self.messages.append(reasoning_message)
|
||||
return None
|
||||
|
||||
# Sequential behavior: process only first tool call, then force reflection.
|
||||
call_id, func_name, func_args = parsed_calls[0]
|
||||
self._append_assistant_tool_calls_message([(call_id, func_name, func_args)])
|
||||
|
||||
execution_result = self._execute_single_native_tool_call(
|
||||
call_id=call_id,
|
||||
func_name=func_name,
|
||||
func_args=func_args,
|
||||
available_functions=available_functions,
|
||||
original_tool=original_tools_by_name.get(func_name),
|
||||
should_execute=True,
|
||||
)
|
||||
tool_finish = self._append_tool_result_and_check_finality(execution_result)
|
||||
if tool_finish:
|
||||
return tool_finish
|
||||
|
||||
reasoning_prompt = self._i18n.slice("post_tool_reasoning")
|
||||
reasoning_message: LLMMessage = {
|
||||
"role": "user",
|
||||
"content": reasoning_prompt,
|
||||
}
|
||||
self.messages.append(reasoning_message)
|
||||
return None
|
||||
|
||||
def _parse_native_tool_call(
|
||||
self, tool_call: Any
|
||||
) -> tuple[str, str, str | dict[str, Any]] | None:
|
||||
if hasattr(tool_call, "function"):
|
||||
# OpenAI-style: has .function.name and .function.arguments
|
||||
call_id = getattr(tool_call, "id", f"call_{id(tool_call)}")
|
||||
func_name = sanitize_tool_name(tool_call.function.name)
|
||||
func_args = tool_call.function.arguments
|
||||
elif hasattr(tool_call, "function_call") and tool_call.function_call:
|
||||
# Gemini-style: has .function_call.name and .function_call.args
|
||||
return call_id, func_name, tool_call.function.arguments
|
||||
if hasattr(tool_call, "function_call") and tool_call.function_call:
|
||||
call_id = f"call_{id(tool_call)}"
|
||||
func_name = sanitize_tool_name(tool_call.function_call.name)
|
||||
func_args = (
|
||||
@@ -716,13 +825,12 @@ class CrewAgentExecutor(CrewAgentExecutorMixin):
|
||||
if tool_call.function_call.args
|
||||
else {}
|
||||
)
|
||||
elif hasattr(tool_call, "name") and hasattr(tool_call, "input"):
|
||||
# Anthropic format: has .name and .input (ToolUseBlock)
|
||||
return call_id, func_name, func_args
|
||||
if hasattr(tool_call, "name") and hasattr(tool_call, "input"):
|
||||
call_id = getattr(tool_call, "id", f"call_{id(tool_call)}")
|
||||
func_name = sanitize_tool_name(tool_call.name)
|
||||
func_args = tool_call.input # Already a dict in Anthropic
|
||||
elif isinstance(tool_call, dict):
|
||||
# Support OpenAI "id", Bedrock "toolUseId", or generate one
|
||||
return call_id, func_name, tool_call.input
|
||||
if isinstance(tool_call, dict):
|
||||
call_id = (
|
||||
tool_call.get("id")
|
||||
or tool_call.get("toolUseId")
|
||||
@@ -733,10 +841,15 @@ class CrewAgentExecutor(CrewAgentExecutorMixin):
|
||||
func_info.get("name", "") or tool_call.get("name", "")
|
||||
)
|
||||
func_args = func_info.get("arguments", "{}") or tool_call.get("input", {})
|
||||
else:
|
||||
return None
|
||||
return call_id, func_name, func_args
|
||||
return None
|
||||
|
||||
def _append_assistant_tool_calls_message(
|
||||
self,
|
||||
parsed_calls: list[tuple[str, str, str | dict[str, Any]]],
|
||||
) -> None:
|
||||
import json
|
||||
|
||||
# Append assistant message with single tool call
|
||||
assistant_message: LLMMessage = {
|
||||
"role": "assistant",
|
||||
"content": None,
|
||||
@@ -751,12 +864,30 @@ class CrewAgentExecutor(CrewAgentExecutorMixin):
|
||||
else json.dumps(func_args),
|
||||
},
|
||||
}
|
||||
for call_id, func_name, func_args in parsed_calls
|
||||
],
|
||||
}
|
||||
|
||||
self.messages.append(assistant_message)
|
||||
|
||||
# Parse arguments for the single tool call
|
||||
def _execute_single_native_tool_call(
|
||||
self,
|
||||
*,
|
||||
call_id: str,
|
||||
func_name: str,
|
||||
func_args: str | dict[str, Any],
|
||||
available_functions: dict[str, Callable[..., Any]],
|
||||
original_tool: Any | None = None,
|
||||
should_execute: bool = True,
|
||||
) -> dict[str, Any]:
|
||||
from datetime import datetime
|
||||
import json
|
||||
|
||||
from crewai.events.types.tool_usage_events import (
|
||||
ToolUsageErrorEvent,
|
||||
ToolUsageFinishedEvent,
|
||||
ToolUsageStartedEvent,
|
||||
)
|
||||
|
||||
if isinstance(func_args, str):
|
||||
try:
|
||||
args_dict = json.loads(func_args)
|
||||
@@ -765,28 +896,26 @@ class CrewAgentExecutor(CrewAgentExecutorMixin):
|
||||
else:
|
||||
args_dict = func_args
|
||||
|
||||
agent_key = getattr(self.agent, "key", "unknown") if self.agent else "unknown"
|
||||
if original_tool is None:
|
||||
for tool in self.original_tools or []:
|
||||
if sanitize_tool_name(tool.name) == func_name:
|
||||
original_tool = tool
|
||||
break
|
||||
|
||||
# Find original tool by matching sanitized name (needed for cache_function and result_as_answer)
|
||||
|
||||
original_tool = None
|
||||
for tool in self.original_tools or []:
|
||||
if sanitize_tool_name(tool.name) == func_name:
|
||||
original_tool = tool
|
||||
break
|
||||
|
||||
# Check if tool has reached max usage count
|
||||
max_usage_reached = False
|
||||
if original_tool:
|
||||
if (
|
||||
hasattr(original_tool, "max_usage_count")
|
||||
and original_tool.max_usage_count is not None
|
||||
and original_tool.current_usage_count >= original_tool.max_usage_count
|
||||
):
|
||||
max_usage_reached = True
|
||||
if not should_execute and original_tool:
|
||||
max_usage_reached = True
|
||||
elif (
|
||||
should_execute
|
||||
and original_tool
|
||||
and getattr(original_tool, "max_usage_count", None) is not None
|
||||
and getattr(original_tool, "current_usage_count", 0)
|
||||
>= original_tool.max_usage_count
|
||||
):
|
||||
max_usage_reached = True
|
||||
|
||||
# Check cache before executing
|
||||
from_cache = False
|
||||
result: str = "Tool not found"
|
||||
input_str = json.dumps(args_dict) if args_dict else ""
|
||||
if self.tools_handler and self.tools_handler.cache:
|
||||
cached_result = self.tools_handler.cache.read(
|
||||
@@ -800,7 +929,7 @@ class CrewAgentExecutor(CrewAgentExecutorMixin):
|
||||
)
|
||||
from_cache = True
|
||||
|
||||
# Emit tool usage started event
|
||||
agent_key = getattr(self.agent, "key", "unknown") if self.agent else "unknown"
|
||||
started_at = datetime.now()
|
||||
crewai_event_bus.emit(
|
||||
self,
|
||||
@@ -816,14 +945,12 @@ class CrewAgentExecutor(CrewAgentExecutorMixin):
|
||||
|
||||
track_delegation_if_needed(func_name, args_dict, self.task)
|
||||
|
||||
# Find the structured tool for hook context
|
||||
structured_tool: CrewStructuredTool | None = None
|
||||
for structured in self.tools or []:
|
||||
if sanitize_tool_name(structured.name) == func_name:
|
||||
structured_tool = structured
|
||||
break
|
||||
|
||||
# Execute before_tool_call hooks
|
||||
hook_blocked = False
|
||||
before_hook_context = ToolCallHookContext(
|
||||
tool_name=func_name,
|
||||
@@ -847,58 +974,44 @@ class CrewAgentExecutor(CrewAgentExecutorMixin):
|
||||
color="red",
|
||||
)
|
||||
|
||||
# If hook blocked execution, set result and skip tool execution
|
||||
if hook_blocked:
|
||||
result = f"Tool execution blocked by hook. Tool: {func_name}"
|
||||
# Execute the tool (only if not cached, not at max usage, and not blocked by hook)
|
||||
elif not from_cache and not max_usage_reached:
|
||||
result = "Tool not found"
|
||||
if func_name in available_functions:
|
||||
try:
|
||||
tool_func = available_functions[func_name]
|
||||
raw_result = tool_func(**args_dict)
|
||||
|
||||
# Add to cache after successful execution (before string conversion)
|
||||
if self.tools_handler and self.tools_handler.cache:
|
||||
should_cache = True
|
||||
if (
|
||||
original_tool
|
||||
and hasattr(original_tool, "cache_function")
|
||||
and callable(original_tool.cache_function)
|
||||
):
|
||||
should_cache = original_tool.cache_function(
|
||||
args_dict, raw_result
|
||||
)
|
||||
if should_cache:
|
||||
self.tools_handler.cache.add(
|
||||
tool=func_name, input=input_str, output=raw_result
|
||||
)
|
||||
|
||||
# Convert to string for message
|
||||
result = (
|
||||
str(raw_result)
|
||||
if not isinstance(raw_result, str)
|
||||
else raw_result
|
||||
)
|
||||
except Exception as e:
|
||||
result = f"Error executing tool: {e}"
|
||||
if self.task:
|
||||
self.task.increment_tools_errors()
|
||||
crewai_event_bus.emit(
|
||||
self,
|
||||
event=ToolUsageErrorEvent(
|
||||
tool_name=func_name,
|
||||
tool_args=args_dict,
|
||||
from_agent=self.agent,
|
||||
from_task=self.task,
|
||||
agent_key=agent_key,
|
||||
error=e,
|
||||
),
|
||||
)
|
||||
error_event_emitted = True
|
||||
elif max_usage_reached and original_tool:
|
||||
# Return error message when max usage limit is reached
|
||||
result = f"Tool '{func_name}' has reached its usage limit of {original_tool.max_usage_count} times and cannot be used anymore."
|
||||
elif not from_cache and func_name in available_functions:
|
||||
try:
|
||||
raw_result = available_functions[func_name](**args_dict)
|
||||
|
||||
if self.tools_handler and self.tools_handler.cache:
|
||||
should_cache = True
|
||||
if (
|
||||
original_tool
|
||||
and hasattr(original_tool, "cache_function")
|
||||
and callable(original_tool.cache_function)
|
||||
):
|
||||
should_cache = original_tool.cache_function(args_dict, raw_result)
|
||||
if should_cache:
|
||||
self.tools_handler.cache.add(
|
||||
tool=func_name, input=input_str, output=raw_result
|
||||
)
|
||||
|
||||
result = str(raw_result) if not isinstance(raw_result, str) else raw_result
|
||||
except Exception as e:
|
||||
result = f"Error executing tool: {e}"
|
||||
if self.task:
|
||||
self.task.increment_tools_errors()
|
||||
crewai_event_bus.emit(
|
||||
self,
|
||||
event=ToolUsageErrorEvent(
|
||||
tool_name=func_name,
|
||||
tool_args=args_dict,
|
||||
from_agent=self.agent,
|
||||
from_task=self.task,
|
||||
agent_key=agent_key,
|
||||
error=e,
|
||||
),
|
||||
)
|
||||
error_event_emitted = True
|
||||
|
||||
after_hook_context = ToolCallHookContext(
|
||||
tool_name=func_name,
|
||||
@@ -938,7 +1051,23 @@ class CrewAgentExecutor(CrewAgentExecutorMixin):
|
||||
),
|
||||
)
|
||||
|
||||
# Append tool result message
|
||||
return {
|
||||
"call_id": call_id,
|
||||
"func_name": func_name,
|
||||
"result": result,
|
||||
"from_cache": from_cache,
|
||||
"original_tool": original_tool,
|
||||
}
|
||||
|
||||
def _append_tool_result_and_check_finality(
|
||||
self, execution_result: dict[str, Any]
|
||||
) -> AgentFinish | None:
|
||||
call_id = cast(str, execution_result["call_id"])
|
||||
func_name = cast(str, execution_result["func_name"])
|
||||
result = cast(str, execution_result["result"])
|
||||
from_cache = cast(bool, execution_result["from_cache"])
|
||||
original_tool = execution_result["original_tool"]
|
||||
|
||||
tool_message: LLMMessage = {
|
||||
"role": "tool",
|
||||
"tool_call_id": call_id,
|
||||
@@ -947,7 +1076,6 @@ class CrewAgentExecutor(CrewAgentExecutorMixin):
|
||||
}
|
||||
self.messages.append(tool_message)
|
||||
|
||||
# Log the tool execution
|
||||
if self.agent and self.agent.verbose:
|
||||
cache_info = " (from cache)" if from_cache else ""
|
||||
self._printer.print(
|
||||
@@ -960,20 +1088,11 @@ class CrewAgentExecutor(CrewAgentExecutorMixin):
|
||||
and hasattr(original_tool, "result_as_answer")
|
||||
and original_tool.result_as_answer
|
||||
):
|
||||
# Return immediately with tool result as final answer
|
||||
return AgentFinish(
|
||||
thought="Tool result is the final answer",
|
||||
output=result,
|
||||
text=result,
|
||||
)
|
||||
|
||||
# Inject post-tool reasoning prompt to enforce analysis
|
||||
reasoning_prompt = self._i18n.slice("post_tool_reasoning")
|
||||
reasoning_message: LLMMessage = {
|
||||
"role": "user",
|
||||
"content": reasoning_prompt,
|
||||
}
|
||||
self.messages.append(reasoning_message)
|
||||
return None
|
||||
|
||||
async def ainvoke(self, inputs: dict[str, Any]) -> dict[str, Any]:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Callable, Coroutine
|
||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||
from datetime import datetime
|
||||
import json
|
||||
import threading
|
||||
@@ -668,9 +669,12 @@ class AgentExecutor(Flow[AgentReActState], CrewAgentExecutorMixin):
|
||||
if not self.state.pending_tool_calls:
|
||||
return "native_tool_completed"
|
||||
|
||||
pending_tool_calls = list(self.state.pending_tool_calls)
|
||||
self.state.pending_tool_calls.clear()
|
||||
|
||||
# Group all tool calls into a single assistant message
|
||||
tool_calls_to_report = []
|
||||
for tool_call in self.state.pending_tool_calls:
|
||||
for tool_call in pending_tool_calls:
|
||||
info = extract_tool_call_info(tool_call)
|
||||
if not info:
|
||||
continue
|
||||
@@ -695,201 +699,85 @@ class AgentExecutor(Flow[AgentReActState], CrewAgentExecutorMixin):
|
||||
"content": None,
|
||||
"tool_calls": tool_calls_to_report,
|
||||
}
|
||||
if all(
|
||||
type(tc).__qualname__ == "Part" for tc in self.state.pending_tool_calls
|
||||
):
|
||||
assistant_message["raw_tool_call_parts"] = list(
|
||||
self.state.pending_tool_calls
|
||||
)
|
||||
if all(type(tc).__qualname__ == "Part" for tc in pending_tool_calls):
|
||||
assistant_message["raw_tool_call_parts"] = list(pending_tool_calls)
|
||||
self.state.messages.append(assistant_message)
|
||||
|
||||
# Now execute each tool
|
||||
while self.state.pending_tool_calls:
|
||||
tool_call = self.state.pending_tool_calls.pop(0)
|
||||
info = extract_tool_call_info(tool_call)
|
||||
if not info:
|
||||
continue
|
||||
runnable_tool_calls = [
|
||||
tool_call
|
||||
for tool_call in pending_tool_calls
|
||||
if extract_tool_call_info(tool_call) is not None
|
||||
]
|
||||
should_parallelize = self._should_parallelize_native_tool_calls(
|
||||
runnable_tool_calls
|
||||
)
|
||||
|
||||
call_id, func_name, func_args = info
|
||||
|
||||
# Parse arguments
|
||||
if isinstance(func_args, str):
|
||||
try:
|
||||
args_dict = json.loads(func_args)
|
||||
except json.JSONDecodeError:
|
||||
args_dict = {}
|
||||
else:
|
||||
args_dict = func_args
|
||||
|
||||
# Get agent_key for event tracking
|
||||
agent_key = (
|
||||
getattr(self.agent, "key", "unknown") if self.agent else "unknown"
|
||||
)
|
||||
|
||||
# Find original tool by matching sanitized name (needed for cache_function and result_as_answer)
|
||||
original_tool = None
|
||||
for tool in self.original_tools or []:
|
||||
if sanitize_tool_name(tool.name) == func_name:
|
||||
original_tool = tool
|
||||
break
|
||||
|
||||
# Check if tool has reached max usage count
|
||||
max_usage_reached = False
|
||||
if (
|
||||
original_tool
|
||||
and original_tool.max_usage_count is not None
|
||||
and original_tool.current_usage_count >= original_tool.max_usage_count
|
||||
):
|
||||
max_usage_reached = True
|
||||
|
||||
# Check cache before executing
|
||||
from_cache = False
|
||||
input_str = json.dumps(args_dict) if args_dict else ""
|
||||
if self.tools_handler and self.tools_handler.cache:
|
||||
cached_result = self.tools_handler.cache.read(
|
||||
tool=func_name, input=input_str
|
||||
execution_results: list[dict[str, Any]] = []
|
||||
if should_parallelize:
|
||||
max_workers = min(8, len(runnable_tool_calls))
|
||||
with ThreadPoolExecutor(max_workers=max_workers) as pool:
|
||||
future_to_idx = {
|
||||
pool.submit(self._execute_single_native_tool_call, tool_call): idx
|
||||
for idx, tool_call in enumerate(runnable_tool_calls)
|
||||
}
|
||||
ordered_results: list[dict[str, Any] | None] = [None] * len(
|
||||
runnable_tool_calls
|
||||
)
|
||||
if cached_result is not None:
|
||||
result = (
|
||||
str(cached_result)
|
||||
if not isinstance(cached_result, str)
|
||||
else cached_result
|
||||
)
|
||||
from_cache = True
|
||||
for future in as_completed(future_to_idx):
|
||||
idx = future_to_idx[future]
|
||||
ordered_results[idx] = future.result()
|
||||
execution_results = [
|
||||
result for result in ordered_results if result is not None
|
||||
]
|
||||
else:
|
||||
# Execute sequentially so result_as_answer tools can short-circuit
|
||||
# immediately without running remaining calls.
|
||||
for tool_call in runnable_tool_calls:
|
||||
execution_result = self._execute_single_native_tool_call(tool_call)
|
||||
call_id = cast(str, execution_result["call_id"])
|
||||
func_name = cast(str, execution_result["func_name"])
|
||||
result = cast(str, execution_result["result"])
|
||||
from_cache = cast(bool, execution_result["from_cache"])
|
||||
original_tool = execution_result["original_tool"]
|
||||
|
||||
# Emit tool usage started event
|
||||
started_at = datetime.now()
|
||||
crewai_event_bus.emit(
|
||||
self,
|
||||
event=ToolUsageStartedEvent(
|
||||
tool_name=func_name,
|
||||
tool_args=args_dict,
|
||||
from_agent=self.agent,
|
||||
from_task=self.task,
|
||||
agent_key=agent_key,
|
||||
),
|
||||
)
|
||||
error_event_emitted = False
|
||||
tool_message: LLMMessage = {
|
||||
"role": "tool",
|
||||
"tool_call_id": call_id,
|
||||
"name": func_name,
|
||||
"content": result,
|
||||
}
|
||||
self.state.messages.append(tool_message)
|
||||
|
||||
track_delegation_if_needed(func_name, args_dict, self.task)
|
||||
|
||||
structured_tool: CrewStructuredTool | None = None
|
||||
for structured in self.tools or []:
|
||||
if sanitize_tool_name(structured.name) == func_name:
|
||||
structured_tool = structured
|
||||
break
|
||||
|
||||
hook_blocked = False
|
||||
before_hook_context = ToolCallHookContext(
|
||||
tool_name=func_name,
|
||||
tool_input=args_dict,
|
||||
tool=structured_tool, # type: ignore[arg-type]
|
||||
agent=self.agent,
|
||||
task=self.task,
|
||||
crew=self.crew,
|
||||
)
|
||||
before_hooks = get_before_tool_call_hooks()
|
||||
try:
|
||||
for hook in before_hooks:
|
||||
hook_result = hook(before_hook_context)
|
||||
if hook_result is False:
|
||||
hook_blocked = True
|
||||
break
|
||||
except Exception as hook_error:
|
||||
if self.agent.verbose:
|
||||
# Log the tool execution
|
||||
if self.agent and self.agent.verbose:
|
||||
cache_info = " (from cache)" if from_cache else ""
|
||||
self._printer.print(
|
||||
content=f"Error in before_tool_call hook: {hook_error}",
|
||||
color="red",
|
||||
content=f"Tool {func_name} executed with result{cache_info}: {result[:200]}...",
|
||||
color="green",
|
||||
)
|
||||
|
||||
if hook_blocked:
|
||||
result = f"Tool execution blocked by hook. Tool: {func_name}"
|
||||
elif not from_cache and not max_usage_reached:
|
||||
result = "Tool not found"
|
||||
if func_name in self._available_functions:
|
||||
try:
|
||||
tool_func = self._available_functions[func_name]
|
||||
raw_result = tool_func(**args_dict)
|
||||
|
||||
# Add to cache after successful execution (before string conversion)
|
||||
if self.tools_handler and self.tools_handler.cache:
|
||||
should_cache = True
|
||||
if original_tool:
|
||||
should_cache = original_tool.cache_function(
|
||||
args_dict, raw_result
|
||||
)
|
||||
if should_cache:
|
||||
self.tools_handler.cache.add(
|
||||
tool=func_name, input=input_str, output=raw_result
|
||||
)
|
||||
|
||||
# Convert to string for message
|
||||
result = (
|
||||
str(raw_result)
|
||||
if not isinstance(raw_result, str)
|
||||
else raw_result
|
||||
)
|
||||
except Exception as e:
|
||||
result = f"Error executing tool: {e}"
|
||||
if self.task:
|
||||
self.task.increment_tools_errors()
|
||||
# Emit tool usage error event
|
||||
crewai_event_bus.emit(
|
||||
self,
|
||||
event=ToolUsageErrorEvent(
|
||||
tool_name=func_name,
|
||||
tool_args=args_dict,
|
||||
from_agent=self.agent,
|
||||
from_task=self.task,
|
||||
agent_key=agent_key,
|
||||
error=e,
|
||||
),
|
||||
)
|
||||
error_event_emitted = True
|
||||
elif max_usage_reached and original_tool:
|
||||
# Return error message when max usage limit is reached
|
||||
result = f"Tool '{func_name}' has reached its usage limit of {original_tool.max_usage_count} times and cannot be used anymore."
|
||||
|
||||
# Execute after_tool_call hooks (even if blocked, to allow logging/monitoring)
|
||||
after_hook_context = ToolCallHookContext(
|
||||
tool_name=func_name,
|
||||
tool_input=args_dict,
|
||||
tool=structured_tool, # type: ignore[arg-type]
|
||||
agent=self.agent,
|
||||
task=self.task,
|
||||
crew=self.crew,
|
||||
tool_result=result,
|
||||
)
|
||||
after_hooks = get_after_tool_call_hooks()
|
||||
try:
|
||||
for after_hook in after_hooks:
|
||||
after_hook_result = after_hook(after_hook_context)
|
||||
if after_hook_result is not None:
|
||||
result = after_hook_result
|
||||
after_hook_context.tool_result = result
|
||||
except Exception as hook_error:
|
||||
if self.agent.verbose:
|
||||
self._printer.print(
|
||||
content=f"Error in after_tool_call hook: {hook_error}",
|
||||
color="red",
|
||||
)
|
||||
|
||||
if not error_event_emitted:
|
||||
crewai_event_bus.emit(
|
||||
self,
|
||||
event=ToolUsageFinishedEvent(
|
||||
if (
|
||||
original_tool
|
||||
and hasattr(original_tool, "result_as_answer")
|
||||
and original_tool.result_as_answer
|
||||
):
|
||||
self.state.current_answer = AgentFinish(
|
||||
thought="Tool result is the final answer",
|
||||
output=result,
|
||||
tool_name=func_name,
|
||||
tool_args=args_dict,
|
||||
from_agent=self.agent,
|
||||
from_task=self.task,
|
||||
agent_key=agent_key,
|
||||
started_at=started_at,
|
||||
finished_at=datetime.now(),
|
||||
),
|
||||
)
|
||||
text=result,
|
||||
)
|
||||
self.state.is_finished = True
|
||||
return "tool_result_is_final"
|
||||
|
||||
return "native_tool_completed"
|
||||
|
||||
for execution_result in execution_results:
|
||||
call_id = cast(str, execution_result["call_id"])
|
||||
func_name = cast(str, execution_result["func_name"])
|
||||
result = cast(str, execution_result["result"])
|
||||
from_cache = cast(bool, execution_result["from_cache"])
|
||||
original_tool = execution_result["original_tool"]
|
||||
|
||||
# Append tool result message
|
||||
tool_message: LLMMessage = {
|
||||
"role": "tool",
|
||||
"tool_call_id": call_id,
|
||||
@@ -922,6 +810,224 @@ class AgentExecutor(Flow[AgentReActState], CrewAgentExecutorMixin):
|
||||
|
||||
return "native_tool_completed"
|
||||
|
||||
def _should_parallelize_native_tool_calls(self, tool_calls: list[Any]) -> bool:
|
||||
"""Determine if native tool calls are safe to run in parallel."""
|
||||
if len(tool_calls) <= 1:
|
||||
return False
|
||||
|
||||
for tool_call in tool_calls:
|
||||
info = extract_tool_call_info(tool_call)
|
||||
if not info:
|
||||
continue
|
||||
_, func_name, _ = info
|
||||
|
||||
original_tool = None
|
||||
for tool in self.original_tools or []:
|
||||
if sanitize_tool_name(tool.name) == func_name:
|
||||
original_tool = tool
|
||||
break
|
||||
|
||||
if not original_tool:
|
||||
continue
|
||||
|
||||
if getattr(original_tool, "result_as_answer", False):
|
||||
return False
|
||||
if getattr(original_tool, "max_usage_count", None) is not None:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def _execute_single_native_tool_call(self, tool_call: Any) -> dict[str, Any]:
|
||||
"""Execute a single native tool call and return metadata/result."""
|
||||
info = extract_tool_call_info(tool_call)
|
||||
if not info:
|
||||
raise ValueError("Invalid native tool call format")
|
||||
|
||||
call_id, func_name, func_args = info
|
||||
|
||||
# Parse arguments
|
||||
if isinstance(func_args, str):
|
||||
try:
|
||||
args_dict = json.loads(func_args)
|
||||
except json.JSONDecodeError:
|
||||
args_dict = {}
|
||||
else:
|
||||
args_dict = func_args
|
||||
|
||||
# Get agent_key for event tracking
|
||||
agent_key = getattr(self.agent, "key", "unknown") if self.agent else "unknown"
|
||||
|
||||
# Find original tool by matching sanitized name (needed for cache_function and result_as_answer)
|
||||
original_tool = None
|
||||
for tool in self.original_tools or []:
|
||||
if sanitize_tool_name(tool.name) == func_name:
|
||||
original_tool = tool
|
||||
break
|
||||
|
||||
# Check if tool has reached max usage count
|
||||
max_usage_reached = False
|
||||
if (
|
||||
original_tool
|
||||
and original_tool.max_usage_count is not None
|
||||
and original_tool.current_usage_count >= original_tool.max_usage_count
|
||||
):
|
||||
max_usage_reached = True
|
||||
|
||||
# Check cache before executing
|
||||
from_cache = False
|
||||
input_str = json.dumps(args_dict) if args_dict else ""
|
||||
if self.tools_handler and self.tools_handler.cache:
|
||||
cached_result = self.tools_handler.cache.read(
|
||||
tool=func_name, input=input_str
|
||||
)
|
||||
if cached_result is not None:
|
||||
result = (
|
||||
str(cached_result)
|
||||
if not isinstance(cached_result, str)
|
||||
else cached_result
|
||||
)
|
||||
from_cache = True
|
||||
|
||||
# Emit tool usage started event
|
||||
started_at = datetime.now()
|
||||
crewai_event_bus.emit(
|
||||
self,
|
||||
event=ToolUsageStartedEvent(
|
||||
tool_name=func_name,
|
||||
tool_args=args_dict,
|
||||
from_agent=self.agent,
|
||||
from_task=self.task,
|
||||
agent_key=agent_key,
|
||||
),
|
||||
)
|
||||
error_event_emitted = False
|
||||
|
||||
track_delegation_if_needed(func_name, args_dict, self.task)
|
||||
|
||||
structured_tool: CrewStructuredTool | None = None
|
||||
for structured in self.tools or []:
|
||||
if sanitize_tool_name(structured.name) == func_name:
|
||||
structured_tool = structured
|
||||
break
|
||||
|
||||
hook_blocked = False
|
||||
before_hook_context = ToolCallHookContext(
|
||||
tool_name=func_name,
|
||||
tool_input=args_dict,
|
||||
tool=structured_tool, # type: ignore[arg-type]
|
||||
agent=self.agent,
|
||||
task=self.task,
|
||||
crew=self.crew,
|
||||
)
|
||||
before_hooks = get_before_tool_call_hooks()
|
||||
try:
|
||||
for hook in before_hooks:
|
||||
hook_result = hook(before_hook_context)
|
||||
if hook_result is False:
|
||||
hook_blocked = True
|
||||
break
|
||||
except Exception as hook_error:
|
||||
if self.agent.verbose:
|
||||
self._printer.print(
|
||||
content=f"Error in before_tool_call hook: {hook_error}",
|
||||
color="red",
|
||||
)
|
||||
|
||||
if hook_blocked:
|
||||
result = f"Tool execution blocked by hook. Tool: {func_name}"
|
||||
elif not from_cache and not max_usage_reached:
|
||||
result = "Tool not found"
|
||||
if func_name in self._available_functions:
|
||||
try:
|
||||
tool_func = self._available_functions[func_name]
|
||||
raw_result = tool_func(**args_dict)
|
||||
|
||||
# Add to cache after successful execution (before string conversion)
|
||||
if self.tools_handler and self.tools_handler.cache:
|
||||
should_cache = True
|
||||
if original_tool:
|
||||
should_cache = original_tool.cache_function(
|
||||
args_dict, raw_result
|
||||
)
|
||||
if should_cache:
|
||||
self.tools_handler.cache.add(
|
||||
tool=func_name, input=input_str, output=raw_result
|
||||
)
|
||||
|
||||
# Convert to string for message
|
||||
result = (
|
||||
str(raw_result)
|
||||
if not isinstance(raw_result, str)
|
||||
else raw_result
|
||||
)
|
||||
except Exception as e:
|
||||
result = f"Error executing tool: {e}"
|
||||
if self.task:
|
||||
self.task.increment_tools_errors()
|
||||
# Emit tool usage error event
|
||||
crewai_event_bus.emit(
|
||||
self,
|
||||
event=ToolUsageErrorEvent(
|
||||
tool_name=func_name,
|
||||
tool_args=args_dict,
|
||||
from_agent=self.agent,
|
||||
from_task=self.task,
|
||||
agent_key=agent_key,
|
||||
error=e,
|
||||
),
|
||||
)
|
||||
error_event_emitted = True
|
||||
elif max_usage_reached and original_tool:
|
||||
# Return error message when max usage limit is reached
|
||||
result = f"Tool '{func_name}' has reached its usage limit of {original_tool.max_usage_count} times and cannot be used anymore."
|
||||
|
||||
# Execute after_tool_call hooks (even if blocked, to allow logging/monitoring)
|
||||
after_hook_context = ToolCallHookContext(
|
||||
tool_name=func_name,
|
||||
tool_input=args_dict,
|
||||
tool=structured_tool, # type: ignore[arg-type]
|
||||
agent=self.agent,
|
||||
task=self.task,
|
||||
crew=self.crew,
|
||||
tool_result=result,
|
||||
)
|
||||
after_hooks = get_after_tool_call_hooks()
|
||||
try:
|
||||
for after_hook in after_hooks:
|
||||
after_hook_result = after_hook(after_hook_context)
|
||||
if after_hook_result is not None:
|
||||
result = after_hook_result
|
||||
after_hook_context.tool_result = result
|
||||
except Exception as hook_error:
|
||||
if self.agent.verbose:
|
||||
self._printer.print(
|
||||
content=f"Error in after_tool_call hook: {hook_error}",
|
||||
color="red",
|
||||
)
|
||||
|
||||
if not error_event_emitted:
|
||||
crewai_event_bus.emit(
|
||||
self,
|
||||
event=ToolUsageFinishedEvent(
|
||||
output=result,
|
||||
tool_name=func_name,
|
||||
tool_args=args_dict,
|
||||
from_agent=self.agent,
|
||||
from_task=self.task,
|
||||
agent_key=agent_key,
|
||||
started_at=started_at,
|
||||
finished_at=datetime.now(),
|
||||
),
|
||||
)
|
||||
|
||||
return {
|
||||
"call_id": call_id,
|
||||
"func_name": func_name,
|
||||
"result": result,
|
||||
"from_cache": from_cache,
|
||||
"original_tool": original_tool,
|
||||
}
|
||||
|
||||
def _extract_tool_name(self, tool_call: Any) -> str:
|
||||
"""Extract tool name from various tool call formats."""
|
||||
if hasattr(tool_call, "function"):
|
||||
|
||||
@@ -10,6 +10,7 @@ import asyncio
|
||||
from collections.abc import (
|
||||
Callable,
|
||||
ItemsView,
|
||||
Iterable,
|
||||
Iterator,
|
||||
KeysView,
|
||||
Sequence,
|
||||
@@ -17,6 +18,7 @@ from collections.abc import (
|
||||
)
|
||||
from concurrent.futures import Future
|
||||
import copy
|
||||
import enum
|
||||
import inspect
|
||||
import logging
|
||||
import threading
|
||||
@@ -27,8 +29,10 @@ from typing import (
|
||||
Generic,
|
||||
Literal,
|
||||
ParamSpec,
|
||||
SupportsIndex,
|
||||
TypeVar,
|
||||
cast,
|
||||
overload,
|
||||
)
|
||||
from uuid import uuid4
|
||||
|
||||
@@ -77,7 +81,12 @@ from crewai.flow.flow_wrappers import (
|
||||
StartMethod,
|
||||
)
|
||||
from crewai.flow.persistence.base import FlowPersistence
|
||||
from crewai.flow.types import FlowExecutionData, FlowMethodName, InputHistoryEntry, PendingListenerKey
|
||||
from crewai.flow.types import (
|
||||
FlowExecutionData,
|
||||
FlowMethodName,
|
||||
InputHistoryEntry,
|
||||
PendingListenerKey,
|
||||
)
|
||||
from crewai.flow.utils import (
|
||||
_extract_all_methods,
|
||||
_extract_all_methods_recursive,
|
||||
@@ -426,8 +435,7 @@ class LockedListProxy(list, Generic[T]): # type: ignore[type-arg]
|
||||
"""
|
||||
|
||||
def __init__(self, lst: list[T], lock: threading.Lock) -> None:
|
||||
# Do NOT call super().__init__() -- we don't want to copy data into
|
||||
# the builtin list storage. All access goes through self._list.
|
||||
super().__init__() # empty builtin list; all access goes through self._list
|
||||
self._list = lst
|
||||
self._lock = lock
|
||||
|
||||
@@ -435,11 +443,11 @@ class LockedListProxy(list, Generic[T]): # type: ignore[type-arg]
|
||||
with self._lock:
|
||||
self._list.append(item)
|
||||
|
||||
def extend(self, items: list[T]) -> None:
|
||||
def extend(self, items: Iterable[T]) -> None:
|
||||
with self._lock:
|
||||
self._list.extend(items)
|
||||
|
||||
def insert(self, index: int, item: T) -> None:
|
||||
def insert(self, index: SupportsIndex, item: T) -> None:
|
||||
with self._lock:
|
||||
self._list.insert(index, item)
|
||||
|
||||
@@ -447,7 +455,7 @@ class LockedListProxy(list, Generic[T]): # type: ignore[type-arg]
|
||||
with self._lock:
|
||||
self._list.remove(item)
|
||||
|
||||
def pop(self, index: int = -1) -> T:
|
||||
def pop(self, index: SupportsIndex = -1) -> T:
|
||||
with self._lock:
|
||||
return self._list.pop(index)
|
||||
|
||||
@@ -455,15 +463,23 @@ class LockedListProxy(list, Generic[T]): # type: ignore[type-arg]
|
||||
with self._lock:
|
||||
self._list.clear()
|
||||
|
||||
def __setitem__(self, index: int, value: T) -> None:
|
||||
@overload
|
||||
def __setitem__(self, index: SupportsIndex, value: T) -> None: ...
|
||||
@overload
|
||||
def __setitem__(self, index: slice, value: Iterable[T]) -> None: ...
|
||||
def __setitem__(self, index: Any, value: Any) -> None:
|
||||
with self._lock:
|
||||
self._list[index] = value
|
||||
|
||||
def __delitem__(self, index: int) -> None:
|
||||
def __delitem__(self, index: SupportsIndex | slice) -> None:
|
||||
with self._lock:
|
||||
del self._list[index]
|
||||
|
||||
def __getitem__(self, index: int) -> T:
|
||||
@overload
|
||||
def __getitem__(self, index: SupportsIndex) -> T: ...
|
||||
@overload
|
||||
def __getitem__(self, index: slice) -> list[T]: ...
|
||||
def __getitem__(self, index: Any) -> Any:
|
||||
return self._list[index]
|
||||
|
||||
def __len__(self) -> int:
|
||||
@@ -481,7 +497,7 @@ class LockedListProxy(list, Generic[T]): # type: ignore[type-arg]
|
||||
def __bool__(self) -> bool:
|
||||
return bool(self._list)
|
||||
|
||||
def __eq__(self, other: object) -> bool: # type: ignore[override]
|
||||
def __eq__(self, other: object) -> bool:
|
||||
"""Compare based on the underlying list contents."""
|
||||
if isinstance(other, LockedListProxy):
|
||||
# Avoid deadlocks by acquiring locks in a consistent order.
|
||||
@@ -492,7 +508,7 @@ class LockedListProxy(list, Generic[T]): # type: ignore[type-arg]
|
||||
with self._lock:
|
||||
return self._list == other
|
||||
|
||||
def __ne__(self, other: object) -> bool: # type: ignore[override]
|
||||
def __ne__(self, other: object) -> bool:
|
||||
return not self.__eq__(other)
|
||||
|
||||
|
||||
@@ -505,8 +521,7 @@ class LockedDictProxy(dict, Generic[T]): # type: ignore[type-arg]
|
||||
"""
|
||||
|
||||
def __init__(self, d: dict[str, T], lock: threading.Lock) -> None:
|
||||
# Do NOT call super().__init__() -- we don't want to copy data into
|
||||
# the builtin dict storage. All access goes through self._dict.
|
||||
super().__init__() # empty builtin dict; all access goes through self._dict
|
||||
self._dict = d
|
||||
self._lock = lock
|
||||
|
||||
@@ -518,11 +533,11 @@ class LockedDictProxy(dict, Generic[T]): # type: ignore[type-arg]
|
||||
with self._lock:
|
||||
del self._dict[key]
|
||||
|
||||
def pop(self, key: str, *default: T) -> T:
|
||||
def pop(self, key: str, *default: T) -> T: # type: ignore[override]
|
||||
with self._lock:
|
||||
return self._dict.pop(key, *default)
|
||||
|
||||
def update(self, other: dict[str, T]) -> None:
|
||||
def update(self, other: dict[str, T]) -> None: # type: ignore[override]
|
||||
with self._lock:
|
||||
self._dict.update(other)
|
||||
|
||||
@@ -530,7 +545,7 @@ class LockedDictProxy(dict, Generic[T]): # type: ignore[type-arg]
|
||||
with self._lock:
|
||||
self._dict.clear()
|
||||
|
||||
def setdefault(self, key: str, default: T) -> T:
|
||||
def setdefault(self, key: str, default: T) -> T: # type: ignore[override]
|
||||
with self._lock:
|
||||
return self._dict.setdefault(key, default)
|
||||
|
||||
@@ -546,16 +561,16 @@ class LockedDictProxy(dict, Generic[T]): # type: ignore[type-arg]
|
||||
def __contains__(self, key: object) -> bool:
|
||||
return key in self._dict
|
||||
|
||||
def keys(self) -> KeysView[str]:
|
||||
def keys(self) -> KeysView[str]: # type: ignore[override]
|
||||
return self._dict.keys()
|
||||
|
||||
def values(self) -> ValuesView[T]:
|
||||
def values(self) -> ValuesView[T]: # type: ignore[override]
|
||||
return self._dict.values()
|
||||
|
||||
def items(self) -> ItemsView[str, T]:
|
||||
def items(self) -> ItemsView[str, T]: # type: ignore[override]
|
||||
return self._dict.items()
|
||||
|
||||
def get(self, key: str, default: T | None = None) -> T | None:
|
||||
def get(self, key: str, default: T | None = None) -> T | None: # type: ignore[override]
|
||||
return self._dict.get(key, default)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
@@ -564,7 +579,7 @@ class LockedDictProxy(dict, Generic[T]): # type: ignore[type-arg]
|
||||
def __bool__(self) -> bool:
|
||||
return bool(self._dict)
|
||||
|
||||
def __eq__(self, other: object) -> bool: # type: ignore[override]
|
||||
def __eq__(self, other: object) -> bool:
|
||||
"""Compare based on the underlying dict contents."""
|
||||
if isinstance(other, LockedDictProxy):
|
||||
# Avoid deadlocks by acquiring locks in a consistent order.
|
||||
@@ -575,7 +590,7 @@ class LockedDictProxy(dict, Generic[T]): # type: ignore[type-arg]
|
||||
with self._lock:
|
||||
return self._dict == other
|
||||
|
||||
def __ne__(self, other: object) -> bool: # type: ignore[override]
|
||||
def __ne__(self, other: object) -> bool:
|
||||
return not self.__eq__(other)
|
||||
|
||||
|
||||
@@ -737,7 +752,9 @@ class Flow(Generic[T], metaclass=FlowMeta):
|
||||
name: str | None = None
|
||||
tracing: bool | None = None
|
||||
stream: bool = False
|
||||
memory: Any = None # Memory | MemoryScope | MemorySlice | None; auto-created if not set
|
||||
memory: Any = (
|
||||
None # Memory | MemoryScope | MemorySlice | None; auto-created if not set
|
||||
)
|
||||
input_provider: Any = None # InputProvider | None; per-flow override for self.ask()
|
||||
|
||||
def __class_getitem__(cls: type[Flow[T]], item: type[T]) -> type[Flow[T]]:
|
||||
@@ -881,7 +898,8 @@ class Flow(Generic[T], metaclass=FlowMeta):
|
||||
"""
|
||||
if self.memory is None:
|
||||
raise ValueError("No memory configured for this flow")
|
||||
return self.memory.extract_memories(content)
|
||||
result: list[str] = self.memory.extract_memories(content)
|
||||
return result
|
||||
|
||||
def _mark_or_listener_fired(self, listener_name: FlowMethodName) -> bool:
|
||||
"""Mark an OR listener as fired atomically.
|
||||
@@ -1352,8 +1370,10 @@ class Flow(Generic[T], metaclass=FlowMeta):
|
||||
ValueError: If structured state model lacks 'id' field
|
||||
TypeError: If state is neither BaseModel nor dictionary
|
||||
"""
|
||||
init_state = self.initial_state
|
||||
|
||||
# Handle case where initial_state is None but we have a type parameter
|
||||
if self.initial_state is None and hasattr(self, "_initial_state_t"):
|
||||
if init_state is None and hasattr(self, "_initial_state_t"):
|
||||
state_type = self._initial_state_t
|
||||
if isinstance(state_type, type):
|
||||
if issubclass(state_type, FlowState):
|
||||
@@ -1377,12 +1397,12 @@ class Flow(Generic[T], metaclass=FlowMeta):
|
||||
return cast(T, {"id": str(uuid4())})
|
||||
|
||||
# Handle case where no initial state is provided
|
||||
if self.initial_state is None:
|
||||
if init_state is None:
|
||||
return cast(T, {"id": str(uuid4())})
|
||||
|
||||
# Handle case where initial_state is a type (class)
|
||||
if isinstance(self.initial_state, type):
|
||||
state_class: type[T] = self.initial_state
|
||||
if isinstance(init_state, type):
|
||||
state_class = init_state
|
||||
if issubclass(state_class, FlowState):
|
||||
return state_class()
|
||||
if issubclass(state_class, BaseModel):
|
||||
@@ -1393,19 +1413,19 @@ class Flow(Generic[T], metaclass=FlowMeta):
|
||||
if not getattr(model_instance, "id", None):
|
||||
object.__setattr__(model_instance, "id", str(uuid4()))
|
||||
return model_instance
|
||||
if self.initial_state is dict:
|
||||
if init_state is dict:
|
||||
return cast(T, {"id": str(uuid4())})
|
||||
|
||||
# Handle dictionary instance case
|
||||
if isinstance(self.initial_state, dict):
|
||||
new_state = dict(self.initial_state) # Copy to avoid mutations
|
||||
if isinstance(init_state, dict):
|
||||
new_state = dict(init_state) # Copy to avoid mutations
|
||||
if "id" not in new_state:
|
||||
new_state["id"] = str(uuid4())
|
||||
return cast(T, new_state)
|
||||
|
||||
# Handle BaseModel instance case
|
||||
if isinstance(self.initial_state, BaseModel):
|
||||
model = cast(BaseModel, self.initial_state)
|
||||
if isinstance(init_state, BaseModel):
|
||||
model = cast(BaseModel, init_state)
|
||||
if not hasattr(model, "id"):
|
||||
raise ValueError("Flow state model must have an 'id' field")
|
||||
|
||||
@@ -2178,6 +2198,8 @@ class Flow(Generic[T], metaclass=FlowMeta):
|
||||
from crewai.flow.async_feedback.types import HumanFeedbackPending
|
||||
|
||||
if isinstance(e, HumanFeedbackPending):
|
||||
e.context.method_name = method_name
|
||||
|
||||
# Auto-save pending feedback (create default persistence if needed)
|
||||
if self._persistence is None:
|
||||
from crewai.flow.persistence import SQLiteFlowPersistence
|
||||
@@ -2277,14 +2299,23 @@ class Flow(Generic[T], metaclass=FlowMeta):
|
||||
router_name, router_input, current_triggering_event_id
|
||||
)
|
||||
if router_result: # Only add non-None results
|
||||
router_results.append(FlowMethodName(str(router_result)))
|
||||
router_result_str = (
|
||||
router_result.value
|
||||
if isinstance(router_result, enum.Enum)
|
||||
else str(router_result)
|
||||
)
|
||||
router_results.append(FlowMethodName(router_result_str))
|
||||
# If this was a human_feedback router, map the outcome to the feedback
|
||||
if self.last_human_feedback is not None:
|
||||
router_result_to_feedback[str(router_result)] = (
|
||||
router_result_to_feedback[router_result_str] = (
|
||||
self.last_human_feedback
|
||||
)
|
||||
current_trigger = (
|
||||
FlowMethodName(str(router_result))
|
||||
FlowMethodName(
|
||||
router_result.value
|
||||
if isinstance(router_result, enum.Enum)
|
||||
else str(router_result)
|
||||
)
|
||||
if router_result is not None
|
||||
else FlowMethodName("") # Update for next iteration of router chain
|
||||
)
|
||||
@@ -2701,7 +2732,10 @@ class Flow(Generic[T], metaclass=FlowMeta):
|
||||
return topic
|
||||
```
|
||||
"""
|
||||
from concurrent.futures import ThreadPoolExecutor, TimeoutError as FuturesTimeoutError
|
||||
from concurrent.futures import (
|
||||
ThreadPoolExecutor,
|
||||
TimeoutError as FuturesTimeoutError,
|
||||
)
|
||||
from datetime import datetime
|
||||
|
||||
from crewai.events.types.flow_events import (
|
||||
@@ -2770,14 +2804,16 @@ class Flow(Generic[T], metaclass=FlowMeta):
|
||||
response = None
|
||||
|
||||
# Record in history
|
||||
self._input_history.append({
|
||||
"message": message,
|
||||
"response": response,
|
||||
"method_name": method_name,
|
||||
"timestamp": datetime.now(),
|
||||
"metadata": metadata,
|
||||
"response_metadata": response_metadata,
|
||||
})
|
||||
self._input_history.append(
|
||||
{
|
||||
"message": message,
|
||||
"response": response,
|
||||
"method_name": method_name,
|
||||
"timestamp": datetime.now(),
|
||||
"metadata": metadata,
|
||||
"response_metadata": response_metadata,
|
||||
}
|
||||
)
|
||||
|
||||
# Emit input received event
|
||||
crewai_event_bus.emit(
|
||||
|
||||
@@ -4,6 +4,7 @@ Tests the Flow-based agent executor implementation including state management,
|
||||
flow methods, routing logic, and error handling.
|
||||
"""
|
||||
|
||||
import time
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
import pytest
|
||||
@@ -462,3 +463,176 @@ class TestFlowInvoke:
|
||||
|
||||
assert result == {"output": "Done"}
|
||||
assert len(executor.state.messages) >= 2
|
||||
|
||||
|
||||
class TestNativeToolExecution:
|
||||
"""Test native tool execution behavior."""
|
||||
|
||||
@pytest.fixture
|
||||
def mock_dependencies(self):
|
||||
llm = Mock()
|
||||
llm.supports_stop_words.return_value = True
|
||||
|
||||
task = Mock()
|
||||
task.name = "Test Task"
|
||||
task.description = "Test"
|
||||
task.human_input = False
|
||||
task.response_model = None
|
||||
|
||||
crew = Mock()
|
||||
crew._memory = None
|
||||
crew.verbose = False
|
||||
crew._train = False
|
||||
|
||||
agent = Mock()
|
||||
agent.id = "test-agent-id"
|
||||
agent.role = "Test Agent"
|
||||
agent.verbose = False
|
||||
agent.key = "test-key"
|
||||
|
||||
prompt = {"prompt": "Test {input} {tool_names} {tools}"}
|
||||
|
||||
tools_handler = Mock()
|
||||
tools_handler.cache = None
|
||||
|
||||
return {
|
||||
"llm": llm,
|
||||
"task": task,
|
||||
"crew": crew,
|
||||
"agent": agent,
|
||||
"prompt": prompt,
|
||||
"max_iter": 10,
|
||||
"tools": [],
|
||||
"tools_names": "",
|
||||
"stop_words": [],
|
||||
"tools_description": "",
|
||||
"tools_handler": tools_handler,
|
||||
}
|
||||
|
||||
def test_execute_native_tool_runs_parallel_for_multiple_calls(
|
||||
self, mock_dependencies
|
||||
):
|
||||
executor = AgentExecutor(**mock_dependencies)
|
||||
|
||||
def slow_one() -> str:
|
||||
time.sleep(0.2)
|
||||
return "one"
|
||||
|
||||
def slow_two() -> str:
|
||||
time.sleep(0.2)
|
||||
return "two"
|
||||
|
||||
executor._available_functions = {"slow_one": slow_one, "slow_two": slow_two}
|
||||
executor.state.pending_tool_calls = [
|
||||
{
|
||||
"id": "call_1",
|
||||
"function": {"name": "slow_one", "arguments": "{}"},
|
||||
},
|
||||
{
|
||||
"id": "call_2",
|
||||
"function": {"name": "slow_two", "arguments": "{}"},
|
||||
},
|
||||
]
|
||||
|
||||
started = time.perf_counter()
|
||||
result = executor.execute_native_tool()
|
||||
elapsed = time.perf_counter() - started
|
||||
|
||||
assert result == "native_tool_completed"
|
||||
assert elapsed < 0.5
|
||||
tool_messages = [m for m in executor.state.messages if m.get("role") == "tool"]
|
||||
assert len(tool_messages) == 2
|
||||
assert tool_messages[0]["tool_call_id"] == "call_1"
|
||||
assert tool_messages[1]["tool_call_id"] == "call_2"
|
||||
|
||||
def test_execute_native_tool_falls_back_to_sequential_for_result_as_answer(
|
||||
self, mock_dependencies
|
||||
):
|
||||
executor = AgentExecutor(**mock_dependencies)
|
||||
|
||||
def slow_one() -> str:
|
||||
time.sleep(0.2)
|
||||
return "one"
|
||||
|
||||
def slow_two() -> str:
|
||||
time.sleep(0.2)
|
||||
return "two"
|
||||
|
||||
result_tool = Mock()
|
||||
result_tool.name = "slow_one"
|
||||
result_tool.result_as_answer = True
|
||||
result_tool.max_usage_count = None
|
||||
result_tool.current_usage_count = 0
|
||||
|
||||
executor.original_tools = [result_tool]
|
||||
executor._available_functions = {"slow_one": slow_one, "slow_two": slow_two}
|
||||
executor.state.pending_tool_calls = [
|
||||
{
|
||||
"id": "call_1",
|
||||
"function": {"name": "slow_one", "arguments": "{}"},
|
||||
},
|
||||
{
|
||||
"id": "call_2",
|
||||
"function": {"name": "slow_two", "arguments": "{}"},
|
||||
},
|
||||
]
|
||||
|
||||
started = time.perf_counter()
|
||||
result = executor.execute_native_tool()
|
||||
elapsed = time.perf_counter() - started
|
||||
|
||||
assert result == "tool_result_is_final"
|
||||
assert elapsed >= 0.2
|
||||
assert elapsed < 0.8
|
||||
assert isinstance(executor.state.current_answer, AgentFinish)
|
||||
assert executor.state.current_answer.output == "one"
|
||||
|
||||
def test_execute_native_tool_result_as_answer_short_circuits_remaining_calls(
|
||||
self, mock_dependencies
|
||||
):
|
||||
executor = AgentExecutor(**mock_dependencies)
|
||||
call_counts = {"slow_one": 0, "slow_two": 0}
|
||||
|
||||
def slow_one() -> str:
|
||||
call_counts["slow_one"] += 1
|
||||
time.sleep(0.2)
|
||||
return "one"
|
||||
|
||||
def slow_two() -> str:
|
||||
call_counts["slow_two"] += 1
|
||||
time.sleep(0.2)
|
||||
return "two"
|
||||
|
||||
result_tool = Mock()
|
||||
result_tool.name = "slow_one"
|
||||
result_tool.result_as_answer = True
|
||||
result_tool.max_usage_count = None
|
||||
result_tool.current_usage_count = 0
|
||||
|
||||
executor.original_tools = [result_tool]
|
||||
executor._available_functions = {"slow_one": slow_one, "slow_two": slow_two}
|
||||
executor.state.pending_tool_calls = [
|
||||
{
|
||||
"id": "call_1",
|
||||
"function": {"name": "slow_one", "arguments": "{}"},
|
||||
},
|
||||
{
|
||||
"id": "call_2",
|
||||
"function": {"name": "slow_two", "arguments": "{}"},
|
||||
},
|
||||
]
|
||||
|
||||
started = time.perf_counter()
|
||||
result = executor.execute_native_tool()
|
||||
elapsed = time.perf_counter() - started
|
||||
|
||||
assert result == "tool_result_is_final"
|
||||
assert isinstance(executor.state.current_answer, AgentFinish)
|
||||
assert executor.state.current_answer.output == "one"
|
||||
assert call_counts["slow_one"] == 1
|
||||
assert call_counts["slow_two"] == 0
|
||||
assert elapsed < 0.5
|
||||
|
||||
tool_messages = [m for m in executor.state.messages if m.get("role") == "tool"]
|
||||
assert len(tool_messages) == 1
|
||||
assert tool_messages[0]["tool_call_id"] == "call_1"
|
||||
|
||||
@@ -6,13 +6,20 @@ when the LLM supports it, across multiple providers.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Generator
|
||||
import os
|
||||
import threading
|
||||
import time
|
||||
from collections import Counter
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from crewai import Agent, Crew, Task
|
||||
from crewai.events import crewai_event_bus
|
||||
from crewai.hooks import register_after_tool_call_hook, register_before_tool_call_hook
|
||||
from crewai.hooks.tool_hooks import ToolCallHookContext
|
||||
from crewai.llm import LLM
|
||||
from crewai.tools.base_tool import BaseTool
|
||||
|
||||
@@ -64,6 +71,73 @@ class FailingTool(BaseTool):
|
||||
def _run(self) -> str:
|
||||
raise Exception("This tool always fails")
|
||||
|
||||
|
||||
class LocalSearchInput(BaseModel):
|
||||
query: str = Field(description="Search query")
|
||||
|
||||
|
||||
class ParallelProbe:
|
||||
"""Thread-safe in-memory recorder for tool execution windows."""
|
||||
|
||||
_lock = threading.Lock()
|
||||
_windows: list[tuple[str, float, float]] = []
|
||||
|
||||
@classmethod
|
||||
def reset(cls) -> None:
|
||||
with cls._lock:
|
||||
cls._windows = []
|
||||
|
||||
@classmethod
|
||||
def record(cls, tool_name: str, start: float, end: float) -> None:
|
||||
with cls._lock:
|
||||
cls._windows.append((tool_name, start, end))
|
||||
|
||||
@classmethod
|
||||
def windows(cls) -> list[tuple[str, float, float]]:
|
||||
with cls._lock:
|
||||
return list(cls._windows)
|
||||
|
||||
|
||||
def _parallel_prompt() -> str:
|
||||
return (
|
||||
"This is a tool-calling compliance test. "
|
||||
"In your next assistant turn, emit exactly 3 tool calls in the same response (parallel tool calls), in this order: "
|
||||
"1) parallel_local_search_one(query='latest OpenAI model release notes'), "
|
||||
"2) parallel_local_search_two(query='latest Anthropic model release notes'), "
|
||||
"3) parallel_local_search_three(query='latest Gemini model release notes'). "
|
||||
"Do not call any other tools and do not answer before those 3 tool calls are emitted. "
|
||||
"After the tool results return, provide a one paragraph summary."
|
||||
)
|
||||
|
||||
|
||||
def _max_concurrency(windows: list[tuple[str, float, float]]) -> int:
|
||||
points: list[tuple[float, int]] = []
|
||||
for _, start, end in windows:
|
||||
points.append((start, 1))
|
||||
points.append((end, -1))
|
||||
points.sort(key=lambda p: (p[0], p[1]))
|
||||
|
||||
current = 0
|
||||
maximum = 0
|
||||
for _, delta in points:
|
||||
current += delta
|
||||
if current > maximum:
|
||||
maximum = current
|
||||
return maximum
|
||||
|
||||
|
||||
def _assert_tools_overlapped() -> None:
|
||||
windows = ParallelProbe.windows()
|
||||
local_windows = [
|
||||
w
|
||||
for w in windows
|
||||
if w[0].startswith("parallel_local_search_")
|
||||
]
|
||||
|
||||
assert len(local_windows) >= 3, f"Expected at least 3 local tool calls, got {len(local_windows)}"
|
||||
assert _max_concurrency(local_windows) >= 2, "Expected overlapping local tool executions"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def calculator_tool() -> CalculatorTool:
|
||||
"""Create a calculator tool for testing."""
|
||||
@@ -82,6 +156,65 @@ def failing_tool() -> BaseTool:
|
||||
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def parallel_tools() -> list[BaseTool]:
|
||||
"""Create local tools used to verify native parallel execution deterministically."""
|
||||
|
||||
class ParallelLocalSearchOne(BaseTool):
|
||||
name: str = "parallel_local_search_one"
|
||||
description: str = "Local search tool #1 for concurrency testing."
|
||||
args_schema: type[BaseModel] = LocalSearchInput
|
||||
|
||||
def _run(self, query: str) -> str:
|
||||
start = time.perf_counter()
|
||||
time.sleep(1.0)
|
||||
end = time.perf_counter()
|
||||
ParallelProbe.record(self.name, start, end)
|
||||
return f"[one] {query}"
|
||||
|
||||
class ParallelLocalSearchTwo(BaseTool):
|
||||
name: str = "parallel_local_search_two"
|
||||
description: str = "Local search tool #2 for concurrency testing."
|
||||
args_schema: type[BaseModel] = LocalSearchInput
|
||||
|
||||
def _run(self, query: str) -> str:
|
||||
start = time.perf_counter()
|
||||
time.sleep(1.0)
|
||||
end = time.perf_counter()
|
||||
ParallelProbe.record(self.name, start, end)
|
||||
return f"[two] {query}"
|
||||
|
||||
class ParallelLocalSearchThree(BaseTool):
|
||||
name: str = "parallel_local_search_three"
|
||||
description: str = "Local search tool #3 for concurrency testing."
|
||||
args_schema: type[BaseModel] = LocalSearchInput
|
||||
|
||||
def _run(self, query: str) -> str:
|
||||
start = time.perf_counter()
|
||||
time.sleep(1.0)
|
||||
end = time.perf_counter()
|
||||
ParallelProbe.record(self.name, start, end)
|
||||
return f"[three] {query}"
|
||||
|
||||
return [
|
||||
ParallelLocalSearchOne(),
|
||||
ParallelLocalSearchTwo(),
|
||||
ParallelLocalSearchThree(),
|
||||
]
|
||||
|
||||
|
||||
def _attach_parallel_probe_handler() -> None:
|
||||
@crewai_event_bus.on(ToolUsageFinishedEvent)
|
||||
def _capture_tool_window(_source, event: ToolUsageFinishedEvent):
|
||||
if not event.tool_name.startswith("parallel_local_search_"):
|
||||
return
|
||||
ParallelProbe.record(
|
||||
event.tool_name,
|
||||
event.started_at.timestamp(),
|
||||
event.finished_at.timestamp(),
|
||||
)
|
||||
|
||||
# =============================================================================
|
||||
# OpenAI Provider Tests
|
||||
# =============================================================================
|
||||
@@ -122,7 +255,7 @@ class TestOpenAINativeToolCalling:
|
||||
self, calculator_tool: CalculatorTool
|
||||
) -> None:
|
||||
"""Test OpenAI agent kickoff with mocked LLM call."""
|
||||
llm = LLM(model="gpt-4o-mini")
|
||||
llm = LLM(model="gpt-5-nano")
|
||||
|
||||
with patch.object(llm, "call", return_value="The answer is 120.") as mock_call:
|
||||
agent = Agent(
|
||||
@@ -146,6 +279,174 @@ class TestOpenAINativeToolCalling:
|
||||
assert mock_call.called
|
||||
assert result is not None
|
||||
|
||||
@pytest.mark.vcr()
|
||||
@pytest.mark.timeout(180)
|
||||
def test_openai_parallel_native_tool_calling_test_crew(
|
||||
self, parallel_tools: list[BaseTool]
|
||||
) -> None:
|
||||
agent = Agent(
|
||||
role="Parallel Tool Agent",
|
||||
goal="Use both tools exactly as instructed",
|
||||
backstory="You follow tool instructions precisely.",
|
||||
tools=parallel_tools,
|
||||
llm=LLM(model="gpt-5-nano", temperature=1),
|
||||
verbose=False,
|
||||
max_iter=3,
|
||||
)
|
||||
task = Task(
|
||||
description=_parallel_prompt(),
|
||||
expected_output="A one sentence summary of both tool outputs",
|
||||
agent=agent,
|
||||
)
|
||||
crew = Crew(agents=[agent], tasks=[task])
|
||||
result = crew.kickoff()
|
||||
assert result is not None
|
||||
_assert_tools_overlapped()
|
||||
|
||||
@pytest.mark.vcr()
|
||||
@pytest.mark.timeout(180)
|
||||
def test_openai_parallel_native_tool_calling_test_agent_kickoff(
|
||||
self, parallel_tools: list[BaseTool]
|
||||
) -> None:
|
||||
agent = Agent(
|
||||
role="Parallel Tool Agent",
|
||||
goal="Use both tools exactly as instructed",
|
||||
backstory="You follow tool instructions precisely.",
|
||||
tools=parallel_tools,
|
||||
llm=LLM(model="gpt-4o-mini"),
|
||||
verbose=False,
|
||||
max_iter=3,
|
||||
)
|
||||
result = agent.kickoff(_parallel_prompt())
|
||||
assert result is not None
|
||||
_assert_tools_overlapped()
|
||||
|
||||
@pytest.mark.vcr()
|
||||
@pytest.mark.timeout(180)
|
||||
def test_openai_parallel_native_tool_calling_tool_hook_parity_crew(
|
||||
self, parallel_tools: list[BaseTool]
|
||||
) -> None:
|
||||
hook_calls: dict[str, list[dict[str, str]]] = {"before": [], "after": []}
|
||||
|
||||
def before_hook(context: ToolCallHookContext) -> bool | None:
|
||||
if context.tool_name.startswith("parallel_local_search_"):
|
||||
hook_calls["before"].append(
|
||||
{
|
||||
"tool_name": context.tool_name,
|
||||
"query": str(context.tool_input.get("query", "")),
|
||||
}
|
||||
)
|
||||
return None
|
||||
|
||||
def after_hook(context: ToolCallHookContext) -> str | None:
|
||||
if context.tool_name.startswith("parallel_local_search_"):
|
||||
hook_calls["after"].append(
|
||||
{
|
||||
"tool_name": context.tool_name,
|
||||
"query": str(context.tool_input.get("query", "")),
|
||||
}
|
||||
)
|
||||
return None
|
||||
|
||||
register_before_tool_call_hook(before_hook)
|
||||
register_after_tool_call_hook(after_hook)
|
||||
|
||||
try:
|
||||
agent = Agent(
|
||||
role="Parallel Tool Agent",
|
||||
goal="Use both tools exactly as instructed",
|
||||
backstory="You follow tool instructions precisely.",
|
||||
tools=parallel_tools,
|
||||
llm=LLM(model="gpt-5-nano", temperature=1),
|
||||
verbose=False,
|
||||
max_iter=3,
|
||||
)
|
||||
task = Task(
|
||||
description=_parallel_prompt(),
|
||||
expected_output="A one sentence summary of both tool outputs",
|
||||
agent=agent,
|
||||
)
|
||||
crew = Crew(agents=[agent], tasks=[task])
|
||||
result = crew.kickoff()
|
||||
|
||||
assert result is not None
|
||||
_assert_tools_overlapped()
|
||||
|
||||
before_names = [call["tool_name"] for call in hook_calls["before"]]
|
||||
after_names = [call["tool_name"] for call in hook_calls["after"]]
|
||||
assert len(before_names) >= 3, "Expected before hooks for all parallel calls"
|
||||
assert Counter(before_names) == Counter(after_names)
|
||||
assert all(call["query"] for call in hook_calls["before"])
|
||||
assert all(call["query"] for call in hook_calls["after"])
|
||||
finally:
|
||||
from crewai.hooks import (
|
||||
unregister_after_tool_call_hook,
|
||||
unregister_before_tool_call_hook,
|
||||
)
|
||||
|
||||
unregister_before_tool_call_hook(before_hook)
|
||||
unregister_after_tool_call_hook(after_hook)
|
||||
|
||||
@pytest.mark.vcr()
|
||||
@pytest.mark.timeout(180)
|
||||
def test_openai_parallel_native_tool_calling_tool_hook_parity_agent_kickoff(
|
||||
self, parallel_tools: list[BaseTool]
|
||||
) -> None:
|
||||
hook_calls: dict[str, list[dict[str, str]]] = {"before": [], "after": []}
|
||||
|
||||
def before_hook(context: ToolCallHookContext) -> bool | None:
|
||||
if context.tool_name.startswith("parallel_local_search_"):
|
||||
hook_calls["before"].append(
|
||||
{
|
||||
"tool_name": context.tool_name,
|
||||
"query": str(context.tool_input.get("query", "")),
|
||||
}
|
||||
)
|
||||
return None
|
||||
|
||||
def after_hook(context: ToolCallHookContext) -> str | None:
|
||||
if context.tool_name.startswith("parallel_local_search_"):
|
||||
hook_calls["after"].append(
|
||||
{
|
||||
"tool_name": context.tool_name,
|
||||
"query": str(context.tool_input.get("query", "")),
|
||||
}
|
||||
)
|
||||
return None
|
||||
|
||||
register_before_tool_call_hook(before_hook)
|
||||
register_after_tool_call_hook(after_hook)
|
||||
|
||||
try:
|
||||
agent = Agent(
|
||||
role="Parallel Tool Agent",
|
||||
goal="Use both tools exactly as instructed",
|
||||
backstory="You follow tool instructions precisely.",
|
||||
tools=parallel_tools,
|
||||
llm=LLM(model="gpt-5-nano", temperature=1),
|
||||
verbose=False,
|
||||
max_iter=3,
|
||||
)
|
||||
result = agent.kickoff(_parallel_prompt())
|
||||
|
||||
assert result is not None
|
||||
_assert_tools_overlapped()
|
||||
|
||||
before_names = [call["tool_name"] for call in hook_calls["before"]]
|
||||
after_names = [call["tool_name"] for call in hook_calls["after"]]
|
||||
assert len(before_names) >= 3, "Expected before hooks for all parallel calls"
|
||||
assert Counter(before_names) == Counter(after_names)
|
||||
assert all(call["query"] for call in hook_calls["before"])
|
||||
assert all(call["query"] for call in hook_calls["after"])
|
||||
finally:
|
||||
from crewai.hooks import (
|
||||
unregister_after_tool_call_hook,
|
||||
unregister_before_tool_call_hook,
|
||||
)
|
||||
|
||||
unregister_before_tool_call_hook(before_hook)
|
||||
unregister_after_tool_call_hook(after_hook)
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# Anthropic Provider Tests
|
||||
@@ -217,6 +518,46 @@ class TestAnthropicNativeToolCalling:
|
||||
assert mock_call.called
|
||||
assert result is not None
|
||||
|
||||
@pytest.mark.vcr()
|
||||
def test_anthropic_parallel_native_tool_calling_test_crew(
|
||||
self, parallel_tools: list[BaseTool]
|
||||
) -> None:
|
||||
agent = Agent(
|
||||
role="Parallel Tool Agent",
|
||||
goal="Use both tools exactly as instructed",
|
||||
backstory="You follow tool instructions precisely.",
|
||||
tools=parallel_tools,
|
||||
llm=LLM(model="anthropic/claude-sonnet-4-6"),
|
||||
verbose=False,
|
||||
max_iter=3,
|
||||
)
|
||||
task = Task(
|
||||
description=_parallel_prompt(),
|
||||
expected_output="A one sentence summary of both tool outputs",
|
||||
agent=agent,
|
||||
)
|
||||
crew = Crew(agents=[agent], tasks=[task])
|
||||
result = crew.kickoff()
|
||||
assert result is not None
|
||||
_assert_tools_overlapped()
|
||||
|
||||
@pytest.mark.vcr()
|
||||
def test_anthropic_parallel_native_tool_calling_test_agent_kickoff(
|
||||
self, parallel_tools: list[BaseTool]
|
||||
) -> None:
|
||||
agent = Agent(
|
||||
role="Parallel Tool Agent",
|
||||
goal="Use both tools exactly as instructed",
|
||||
backstory="You follow tool instructions precisely.",
|
||||
tools=parallel_tools,
|
||||
llm=LLM(model="anthropic/claude-sonnet-4-6"),
|
||||
verbose=False,
|
||||
max_iter=3,
|
||||
)
|
||||
result = agent.kickoff(_parallel_prompt())
|
||||
assert result is not None
|
||||
_assert_tools_overlapped()
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# Google/Gemini Provider Tests
|
||||
@@ -247,7 +588,7 @@ class TestGeminiNativeToolCalling:
|
||||
goal="Help users with mathematical calculations",
|
||||
backstory="You are a helpful math assistant.",
|
||||
tools=[calculator_tool],
|
||||
llm=LLM(model="gemini/gemini-2.0-flash-exp"),
|
||||
llm=LLM(model="gemini/gemini-2.5-flash"),
|
||||
)
|
||||
|
||||
task = Task(
|
||||
@@ -266,7 +607,7 @@ class TestGeminiNativeToolCalling:
|
||||
self, calculator_tool: CalculatorTool
|
||||
) -> None:
|
||||
"""Test Gemini agent kickoff with mocked LLM call."""
|
||||
llm = LLM(model="gemini/gemini-2.0-flash-001")
|
||||
llm = LLM(model="gemini/gemini-2.5-flash")
|
||||
|
||||
with patch.object(llm, "call", return_value="The answer is 120.") as mock_call:
|
||||
agent = Agent(
|
||||
@@ -290,6 +631,46 @@ class TestGeminiNativeToolCalling:
|
||||
assert mock_call.called
|
||||
assert result is not None
|
||||
|
||||
@pytest.mark.vcr()
|
||||
def test_gemini_parallel_native_tool_calling_test_crew(
|
||||
self, parallel_tools: list[BaseTool]
|
||||
) -> None:
|
||||
agent = Agent(
|
||||
role="Parallel Tool Agent",
|
||||
goal="Use both tools exactly as instructed",
|
||||
backstory="You follow tool instructions precisely.",
|
||||
tools=parallel_tools,
|
||||
llm=LLM(model="gemini/gemini-2.5-flash"),
|
||||
verbose=False,
|
||||
max_iter=3,
|
||||
)
|
||||
task = Task(
|
||||
description=_parallel_prompt(),
|
||||
expected_output="A one sentence summary of both tool outputs",
|
||||
agent=agent,
|
||||
)
|
||||
crew = Crew(agents=[agent], tasks=[task])
|
||||
result = crew.kickoff()
|
||||
assert result is not None
|
||||
_assert_tools_overlapped()
|
||||
|
||||
@pytest.mark.vcr()
|
||||
def test_gemini_parallel_native_tool_calling_test_agent_kickoff(
|
||||
self, parallel_tools: list[BaseTool]
|
||||
) -> None:
|
||||
agent = Agent(
|
||||
role="Parallel Tool Agent",
|
||||
goal="Use both tools exactly as instructed",
|
||||
backstory="You follow tool instructions precisely.",
|
||||
tools=parallel_tools,
|
||||
llm=LLM(model="gemini/gemini-2.5-flash"),
|
||||
verbose=False,
|
||||
max_iter=3,
|
||||
)
|
||||
result = agent.kickoff(_parallel_prompt())
|
||||
assert result is not None
|
||||
_assert_tools_overlapped()
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# Azure Provider Tests
|
||||
@@ -324,7 +705,7 @@ class TestAzureNativeToolCalling:
|
||||
goal="Help users with mathematical calculations",
|
||||
backstory="You are a helpful math assistant.",
|
||||
tools=[calculator_tool],
|
||||
llm=LLM(model="azure/gpt-4o-mini"),
|
||||
llm=LLM(model="azure/gpt-5-nano"),
|
||||
verbose=False,
|
||||
max_iter=3,
|
||||
)
|
||||
@@ -347,7 +728,7 @@ class TestAzureNativeToolCalling:
|
||||
) -> None:
|
||||
"""Test Azure agent kickoff with mocked LLM call."""
|
||||
llm = LLM(
|
||||
model="azure/gpt-4o-mini",
|
||||
model="azure/gpt-5-nano",
|
||||
api_key="test-key",
|
||||
base_url="https://test.openai.azure.com",
|
||||
)
|
||||
@@ -374,6 +755,46 @@ class TestAzureNativeToolCalling:
|
||||
assert mock_call.called
|
||||
assert result is not None
|
||||
|
||||
@pytest.mark.vcr()
|
||||
def test_azure_parallel_native_tool_calling_test_crew(
|
||||
self, parallel_tools: list[BaseTool]
|
||||
) -> None:
|
||||
agent = Agent(
|
||||
role="Parallel Tool Agent",
|
||||
goal="Use both tools exactly as instructed",
|
||||
backstory="You follow tool instructions precisely.",
|
||||
tools=parallel_tools,
|
||||
llm=LLM(model="azure/gpt-5-nano"),
|
||||
verbose=False,
|
||||
max_iter=3,
|
||||
)
|
||||
task = Task(
|
||||
description=_parallel_prompt(),
|
||||
expected_output="A one sentence summary of both tool outputs",
|
||||
agent=agent,
|
||||
)
|
||||
crew = Crew(agents=[agent], tasks=[task])
|
||||
result = crew.kickoff()
|
||||
assert result is not None
|
||||
_assert_tools_overlapped()
|
||||
|
||||
@pytest.mark.vcr()
|
||||
def test_azure_parallel_native_tool_calling_test_agent_kickoff(
|
||||
self, parallel_tools: list[BaseTool]
|
||||
) -> None:
|
||||
agent = Agent(
|
||||
role="Parallel Tool Agent",
|
||||
goal="Use both tools exactly as instructed",
|
||||
backstory="You follow tool instructions precisely.",
|
||||
tools=parallel_tools,
|
||||
llm=LLM(model="azure/gpt-5-nano"),
|
||||
verbose=False,
|
||||
max_iter=3,
|
||||
)
|
||||
result = agent.kickoff(_parallel_prompt())
|
||||
assert result is not None
|
||||
_assert_tools_overlapped()
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# Bedrock Provider Tests
|
||||
@@ -384,18 +805,30 @@ class TestBedrockNativeToolCalling:
|
||||
"""Tests for native tool calling with AWS Bedrock models."""
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def mock_aws_env(self):
|
||||
"""Mock AWS environment variables for tests."""
|
||||
env_vars = {
|
||||
"AWS_ACCESS_KEY_ID": "test-key",
|
||||
"AWS_SECRET_ACCESS_KEY": "test-secret",
|
||||
"AWS_REGION": "us-east-1",
|
||||
}
|
||||
if "AWS_ACCESS_KEY_ID" not in os.environ:
|
||||
with patch.dict(os.environ, env_vars):
|
||||
yield
|
||||
else:
|
||||
yield
|
||||
def validate_bedrock_credentials_for_live_recording(self):
|
||||
"""Run Bedrock tests only when explicitly enabled."""
|
||||
run_live_bedrock = os.getenv("RUN_BEDROCK_LIVE_TESTS", "false").lower() == "true"
|
||||
|
||||
if not run_live_bedrock:
|
||||
pytest.skip(
|
||||
"Skipping Bedrock tests by default. "
|
||||
"Set RUN_BEDROCK_LIVE_TESTS=true with valid AWS credentials to enable."
|
||||
)
|
||||
|
||||
access_key = os.getenv("AWS_ACCESS_KEY_ID", "")
|
||||
secret_key = os.getenv("AWS_SECRET_ACCESS_KEY", "")
|
||||
if (
|
||||
not access_key
|
||||
or not secret_key
|
||||
or access_key.startswith(("fake-", "test-"))
|
||||
or secret_key.startswith(("fake-", "test-"))
|
||||
):
|
||||
pytest.skip(
|
||||
"Skipping Bedrock tests: valid AWS credentials are required when "
|
||||
"RUN_BEDROCK_LIVE_TESTS=true."
|
||||
)
|
||||
|
||||
yield
|
||||
|
||||
@pytest.mark.vcr()
|
||||
def test_bedrock_agent_kickoff_with_tools_mocked(
|
||||
@@ -427,6 +860,46 @@ class TestBedrockNativeToolCalling:
|
||||
assert result.raw is not None
|
||||
assert "120" in str(result.raw)
|
||||
|
||||
@pytest.mark.vcr()
|
||||
def test_bedrock_parallel_native_tool_calling_test_crew(
|
||||
self, parallel_tools: list[BaseTool]
|
||||
) -> None:
|
||||
agent = Agent(
|
||||
role="Parallel Tool Agent",
|
||||
goal="Use both tools exactly as instructed",
|
||||
backstory="You follow tool instructions precisely.",
|
||||
tools=parallel_tools,
|
||||
llm=LLM(model="bedrock/anthropic.claude-3-haiku-20240307-v1:0"),
|
||||
verbose=False,
|
||||
max_iter=3,
|
||||
)
|
||||
task = Task(
|
||||
description=_parallel_prompt(),
|
||||
expected_output="A one sentence summary of both tool outputs",
|
||||
agent=agent,
|
||||
)
|
||||
crew = Crew(agents=[agent], tasks=[task])
|
||||
result = crew.kickoff()
|
||||
assert result is not None
|
||||
_assert_tools_overlapped()
|
||||
|
||||
@pytest.mark.vcr()
|
||||
def test_bedrock_parallel_native_tool_calling_test_agent_kickoff(
|
||||
self, parallel_tools: list[BaseTool]
|
||||
) -> None:
|
||||
agent = Agent(
|
||||
role="Parallel Tool Agent",
|
||||
goal="Use both tools exactly as instructed",
|
||||
backstory="You follow tool instructions precisely.",
|
||||
tools=parallel_tools,
|
||||
llm=LLM(model="bedrock/anthropic.claude-3-haiku-20240307-v1:0"),
|
||||
verbose=False,
|
||||
max_iter=3,
|
||||
)
|
||||
result = agent.kickoff(_parallel_prompt())
|
||||
assert result is not None
|
||||
_assert_tools_overlapped()
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# Cross-Provider Native Tool Calling Behavior Tests
|
||||
@@ -439,7 +912,7 @@ class TestNativeToolCallingBehavior:
|
||||
def test_supports_function_calling_check(self) -> None:
|
||||
"""Test that supports_function_calling() is properly checked."""
|
||||
# OpenAI should support function calling
|
||||
openai_llm = LLM(model="gpt-4o-mini")
|
||||
openai_llm = LLM(model="gpt-5-nano")
|
||||
assert hasattr(openai_llm, "supports_function_calling")
|
||||
assert openai_llm.supports_function_calling() is True
|
||||
|
||||
@@ -475,7 +948,7 @@ class TestNativeToolCallingTokenUsage:
|
||||
goal="Perform calculations efficiently",
|
||||
backstory="You calculate things.",
|
||||
tools=[calculator_tool],
|
||||
llm=LLM(model="gpt-4o-mini"),
|
||||
llm=LLM(model="gpt-5-nano"),
|
||||
verbose=False,
|
||||
max_iter=3,
|
||||
)
|
||||
@@ -519,7 +992,7 @@ def test_native_tool_calling_error_handling(failing_tool: FailingTool):
|
||||
goal="Perform calculations efficiently",
|
||||
backstory="You calculate things.",
|
||||
tools=[failing_tool],
|
||||
llm=LLM(model="gpt-4o-mini"),
|
||||
llm=LLM(model="gpt-5-nano"),
|
||||
verbose=False,
|
||||
max_iter=3,
|
||||
)
|
||||
@@ -578,7 +1051,7 @@ class TestMaxUsageCountWithNativeToolCalling:
|
||||
goal="Call the counting tool multiple times",
|
||||
backstory="You are an agent that counts things.",
|
||||
tools=[tool],
|
||||
llm=LLM(model="gpt-4o-mini"),
|
||||
llm=LLM(model="gpt-5-nano"),
|
||||
verbose=False,
|
||||
max_iter=5,
|
||||
)
|
||||
@@ -606,7 +1079,7 @@ class TestMaxUsageCountWithNativeToolCalling:
|
||||
goal="Use the counting tool as many times as requested",
|
||||
backstory="You are an agent that counts things. You must try to use the tool for each value requested.",
|
||||
tools=[tool],
|
||||
llm=LLM(model="gpt-4o-mini"),
|
||||
llm=LLM(model="gpt-5-nano"),
|
||||
verbose=False,
|
||||
max_iter=5,
|
||||
)
|
||||
@@ -638,7 +1111,7 @@ class TestMaxUsageCountWithNativeToolCalling:
|
||||
goal="Use the counting tool exactly as requested",
|
||||
backstory="You are an agent that counts things precisely.",
|
||||
tools=[tool],
|
||||
llm=LLM(model="gpt-4o-mini"),
|
||||
llm=LLM(model="gpt-5-nano"),
|
||||
verbose=False,
|
||||
max_iter=5,
|
||||
)
|
||||
@@ -653,5 +1126,6 @@ class TestMaxUsageCountWithNativeToolCalling:
|
||||
result = crew.kickoff()
|
||||
|
||||
assert result is not None
|
||||
# Verify usage count was incremented for each successful call
|
||||
assert tool.current_usage_count == 2
|
||||
# Verify the requested calls occurred while keeping usage bounded.
|
||||
assert tool.current_usage_count >= 2
|
||||
assert tool.current_usage_count <= tool.max_usage_count
|
||||
|
||||
@@ -0,0 +1,247 @@
|
||||
interactions:
|
||||
- request:
|
||||
body: '{"max_tokens":4096,"messages":[{"role":"user","content":"\nCurrent Task:
|
||||
This is a tool-calling compliance test. In your next assistant turn, emit exactly
|
||||
3 tool calls in the same response (parallel tool calls), in this order: 1) parallel_local_search_one(query=''latest
|
||||
OpenAI model release notes''), 2) parallel_local_search_two(query=''latest Anthropic
|
||||
model release notes''), 3) parallel_local_search_three(query=''latest Gemini
|
||||
model release notes''). Do not call any other tools and do not answer before
|
||||
those 3 tool calls are emitted. After the tool results return, provide a one
|
||||
paragraph summary."}],"model":"claude-sonnet-4-6","stop_sequences":["\nObservation:"],"stream":false,"system":"You
|
||||
are Parallel Tool Agent. You follow tool instructions precisely.\nYour personal
|
||||
goal is: Use both tools exactly as instructed","tools":[{"name":"parallel_local_search_one","description":"Local
|
||||
search tool #1 for concurrency testing.","input_schema":{"properties":{"query":{"description":"Search
|
||||
query","title":"Query","type":"string"}},"required":["query"],"type":"object","additionalProperties":false}},{"name":"parallel_local_search_two","description":"Local
|
||||
search tool #2 for concurrency testing.","input_schema":{"properties":{"query":{"description":"Search
|
||||
query","title":"Query","type":"string"}},"required":["query"],"type":"object","additionalProperties":false}},{"name":"parallel_local_search_three","description":"Local
|
||||
search tool #3 for concurrency testing.","input_schema":{"properties":{"query":{"description":"Search
|
||||
query","title":"Query","type":"string"}},"required":["query"],"type":"object","additionalProperties":false}}]}'
|
||||
headers:
|
||||
User-Agent:
|
||||
- X-USER-AGENT-XXX
|
||||
accept:
|
||||
- application/json
|
||||
accept-encoding:
|
||||
- ACCEPT-ENCODING-XXX
|
||||
anthropic-version:
|
||||
- '2023-06-01'
|
||||
connection:
|
||||
- keep-alive
|
||||
content-length:
|
||||
- '1639'
|
||||
content-type:
|
||||
- application/json
|
||||
host:
|
||||
- api.anthropic.com
|
||||
x-api-key:
|
||||
- X-API-KEY-XXX
|
||||
x-stainless-arch:
|
||||
- X-STAINLESS-ARCH-XXX
|
||||
x-stainless-async:
|
||||
- 'false'
|
||||
x-stainless-lang:
|
||||
- python
|
||||
x-stainless-os:
|
||||
- X-STAINLESS-OS-XXX
|
||||
x-stainless-package-version:
|
||||
- 0.73.0
|
||||
x-stainless-retry-count:
|
||||
- '0'
|
||||
x-stainless-runtime:
|
||||
- CPython
|
||||
x-stainless-runtime-version:
|
||||
- 3.13.3
|
||||
x-stainless-timeout:
|
||||
- NOT_GIVEN
|
||||
method: POST
|
||||
uri: https://api.anthropic.com/v1/messages
|
||||
response:
|
||||
body:
|
||||
string: '{"model":"claude-sonnet-4-6","id":"msg_01XeN1XTXZgmPyLMMGjivabb","type":"message","role":"assistant","content":[{"type":"text","text":"I''ll
|
||||
execute all 3 parallel searches simultaneously right now!"},{"type":"tool_use","id":"toolu_01NwzvrxEz6tvT3A8ydvMtHu","name":"parallel_local_search_one","input":{"query":"latest
|
||||
OpenAI model release notes"},"caller":{"type":"direct"}},{"type":"tool_use","id":"toolu_01YCxzSB1suk9uPVC1uwfHz9","name":"parallel_local_search_two","input":{"query":"latest
|
||||
Anthropic model release notes"},"caller":{"type":"direct"}},{"type":"tool_use","id":"toolu_01Mauvxzv58eDY7pUt9HMKGy","name":"parallel_local_search_three","input":{"query":"latest
|
||||
Gemini model release notes"},"caller":{"type":"direct"}}],"stop_reason":"tool_use","stop_sequence":null,"usage":{"input_tokens":914,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":169,"service_tier":"standard","inference_geo":"global"}}'
|
||||
headers:
|
||||
CF-RAY:
|
||||
- CF-RAY-XXX
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Security-Policy:
|
||||
- CSP-FILTERED
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Wed, 18 Feb 2026 23:54:43 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
X-Robots-Tag:
|
||||
- none
|
||||
anthropic-organization-id:
|
||||
- ANTHROPIC-ORGANIZATION-ID-XXX
|
||||
anthropic-ratelimit-input-tokens-limit:
|
||||
- ANTHROPIC-RATELIMIT-INPUT-TOKENS-LIMIT-XXX
|
||||
anthropic-ratelimit-input-tokens-remaining:
|
||||
- ANTHROPIC-RATELIMIT-INPUT-TOKENS-REMAINING-XXX
|
||||
anthropic-ratelimit-input-tokens-reset:
|
||||
- ANTHROPIC-RATELIMIT-INPUT-TOKENS-RESET-XXX
|
||||
anthropic-ratelimit-output-tokens-limit:
|
||||
- ANTHROPIC-RATELIMIT-OUTPUT-TOKENS-LIMIT-XXX
|
||||
anthropic-ratelimit-output-tokens-remaining:
|
||||
- ANTHROPIC-RATELIMIT-OUTPUT-TOKENS-REMAINING-XXX
|
||||
anthropic-ratelimit-output-tokens-reset:
|
||||
- ANTHROPIC-RATELIMIT-OUTPUT-TOKENS-RESET-XXX
|
||||
anthropic-ratelimit-requests-limit:
|
||||
- '20000'
|
||||
anthropic-ratelimit-requests-remaining:
|
||||
- '19999'
|
||||
anthropic-ratelimit-requests-reset:
|
||||
- '2026-02-18T23:54:41Z'
|
||||
anthropic-ratelimit-tokens-limit:
|
||||
- ANTHROPIC-RATELIMIT-TOKENS-LIMIT-XXX
|
||||
anthropic-ratelimit-tokens-remaining:
|
||||
- ANTHROPIC-RATELIMIT-TOKENS-REMAINING-XXX
|
||||
anthropic-ratelimit-tokens-reset:
|
||||
- ANTHROPIC-RATELIMIT-TOKENS-RESET-XXX
|
||||
cf-cache-status:
|
||||
- DYNAMIC
|
||||
request-id:
|
||||
- REQUEST-ID-XXX
|
||||
strict-transport-security:
|
||||
- STS-XXX
|
||||
x-envoy-upstream-service-time:
|
||||
- '2099'
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: '{"max_tokens":4096,"messages":[{"role":"user","content":"\nCurrent Task:
|
||||
This is a tool-calling compliance test. In your next assistant turn, emit exactly
|
||||
3 tool calls in the same response (parallel tool calls), in this order: 1) parallel_local_search_one(query=''latest
|
||||
OpenAI model release notes''), 2) parallel_local_search_two(query=''latest Anthropic
|
||||
model release notes''), 3) parallel_local_search_three(query=''latest Gemini
|
||||
model release notes''). Do not call any other tools and do not answer before
|
||||
those 3 tool calls are emitted. After the tool results return, provide a one
|
||||
paragraph summary."},{"role":"assistant","content":[{"type":"tool_use","id":"toolu_01NwzvrxEz6tvT3A8ydvMtHu","name":"parallel_local_search_one","input":{"query":"latest
|
||||
OpenAI model release notes"}},{"type":"tool_use","id":"toolu_01YCxzSB1suk9uPVC1uwfHz9","name":"parallel_local_search_two","input":{"query":"latest
|
||||
Anthropic model release notes"}},{"type":"tool_use","id":"toolu_01Mauvxzv58eDY7pUt9HMKGy","name":"parallel_local_search_three","input":{"query":"latest
|
||||
Gemini model release notes"}}]},{"role":"user","content":[{"type":"tool_result","tool_use_id":"toolu_01NwzvrxEz6tvT3A8ydvMtHu","content":"[one]
|
||||
latest OpenAI model release notes"},{"type":"tool_result","tool_use_id":"toolu_01YCxzSB1suk9uPVC1uwfHz9","content":"[two]
|
||||
latest Anthropic model release notes"},{"type":"tool_result","tool_use_id":"toolu_01Mauvxzv58eDY7pUt9HMKGy","content":"[three]
|
||||
latest Gemini model release notes"}]}],"model":"claude-sonnet-4-6","stop_sequences":["\nObservation:"],"stream":false,"system":"You
|
||||
are Parallel Tool Agent. You follow tool instructions precisely.\nYour personal
|
||||
goal is: Use both tools exactly as instructed","tools":[{"name":"parallel_local_search_one","description":"Local
|
||||
search tool #1 for concurrency testing.","input_schema":{"properties":{"query":{"description":"Search
|
||||
query","title":"Query","type":"string"}},"required":["query"],"type":"object","additionalProperties":false}},{"name":"parallel_local_search_two","description":"Local
|
||||
search tool #2 for concurrency testing.","input_schema":{"properties":{"query":{"description":"Search
|
||||
query","title":"Query","type":"string"}},"required":["query"],"type":"object","additionalProperties":false}},{"name":"parallel_local_search_three","description":"Local
|
||||
search tool #3 for concurrency testing.","input_schema":{"properties":{"query":{"description":"Search
|
||||
query","title":"Query","type":"string"}},"required":["query"],"type":"object","additionalProperties":false}}]}'
|
||||
headers:
|
||||
User-Agent:
|
||||
- X-USER-AGENT-XXX
|
||||
accept:
|
||||
- application/json
|
||||
accept-encoding:
|
||||
- ACCEPT-ENCODING-XXX
|
||||
anthropic-version:
|
||||
- '2023-06-01'
|
||||
connection:
|
||||
- keep-alive
|
||||
content-length:
|
||||
- '2517'
|
||||
content-type:
|
||||
- application/json
|
||||
host:
|
||||
- api.anthropic.com
|
||||
x-api-key:
|
||||
- X-API-KEY-XXX
|
||||
x-stainless-arch:
|
||||
- X-STAINLESS-ARCH-XXX
|
||||
x-stainless-async:
|
||||
- 'false'
|
||||
x-stainless-lang:
|
||||
- python
|
||||
x-stainless-os:
|
||||
- X-STAINLESS-OS-XXX
|
||||
x-stainless-package-version:
|
||||
- 0.73.0
|
||||
x-stainless-retry-count:
|
||||
- '0'
|
||||
x-stainless-runtime:
|
||||
- CPython
|
||||
x-stainless-runtime-version:
|
||||
- 3.13.3
|
||||
x-stainless-timeout:
|
||||
- NOT_GIVEN
|
||||
method: POST
|
||||
uri: https://api.anthropic.com/v1/messages
|
||||
response:
|
||||
body:
|
||||
string: "{\"model\":\"claude-sonnet-4-6\",\"id\":\"msg_01PFXqwwdwwHWadPdtNU5tUZ\",\"type\":\"message\",\"role\":\"assistant\",\"content\":[{\"type\":\"text\",\"text\":\"The
|
||||
three parallel searches were executed successfully, each targeting the latest
|
||||
release notes for the leading AI model families. The search results confirm
|
||||
that queries were dispatched simultaneously to retrieve the most recent developments
|
||||
from **OpenAI** (via tool one), **Anthropic** (via tool two), and **Google's
|
||||
Gemini** (via tool three). While the local search tools returned placeholder
|
||||
outputs in this test environment rather than detailed release notes, the structure
|
||||
of the test validates that all three parallel tool calls were emitted correctly
|
||||
and in the specified order \u2014 demonstrating proper concurrent tool-call
|
||||
behavior with no dependencies between the three independent searches.\"}],\"stop_reason\":\"end_turn\",\"stop_sequence\":null,\"usage\":{\"input_tokens\":1197,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"cache_creation\":{\"ephemeral_5m_input_tokens\":0,\"ephemeral_1h_input_tokens\":0},\"output_tokens\":131,\"service_tier\":\"standard\",\"inference_geo\":\"global\"}}"
|
||||
headers:
|
||||
CF-RAY:
|
||||
- CF-RAY-XXX
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Security-Policy:
|
||||
- CSP-FILTERED
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Wed, 18 Feb 2026 23:54:49 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
X-Robots-Tag:
|
||||
- none
|
||||
anthropic-organization-id:
|
||||
- ANTHROPIC-ORGANIZATION-ID-XXX
|
||||
anthropic-ratelimit-input-tokens-limit:
|
||||
- ANTHROPIC-RATELIMIT-INPUT-TOKENS-LIMIT-XXX
|
||||
anthropic-ratelimit-input-tokens-remaining:
|
||||
- ANTHROPIC-RATELIMIT-INPUT-TOKENS-REMAINING-XXX
|
||||
anthropic-ratelimit-input-tokens-reset:
|
||||
- ANTHROPIC-RATELIMIT-INPUT-TOKENS-RESET-XXX
|
||||
anthropic-ratelimit-output-tokens-limit:
|
||||
- ANTHROPIC-RATELIMIT-OUTPUT-TOKENS-LIMIT-XXX
|
||||
anthropic-ratelimit-output-tokens-remaining:
|
||||
- ANTHROPIC-RATELIMIT-OUTPUT-TOKENS-REMAINING-XXX
|
||||
anthropic-ratelimit-output-tokens-reset:
|
||||
- ANTHROPIC-RATELIMIT-OUTPUT-TOKENS-RESET-XXX
|
||||
anthropic-ratelimit-requests-limit:
|
||||
- '20000'
|
||||
anthropic-ratelimit-requests-remaining:
|
||||
- '19999'
|
||||
anthropic-ratelimit-requests-reset:
|
||||
- '2026-02-18T23:54:44Z'
|
||||
anthropic-ratelimit-tokens-limit:
|
||||
- ANTHROPIC-RATELIMIT-TOKENS-LIMIT-XXX
|
||||
anthropic-ratelimit-tokens-remaining:
|
||||
- ANTHROPIC-RATELIMIT-TOKENS-REMAINING-XXX
|
||||
anthropic-ratelimit-tokens-reset:
|
||||
- ANTHROPIC-RATELIMIT-TOKENS-RESET-XXX
|
||||
cf-cache-status:
|
||||
- DYNAMIC
|
||||
request-id:
|
||||
- REQUEST-ID-XXX
|
||||
strict-transport-security:
|
||||
- STS-XXX
|
||||
x-envoy-upstream-service-time:
|
||||
- '4092'
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
version: 1
|
||||
@@ -0,0 +1,254 @@
|
||||
interactions:
|
||||
- request:
|
||||
body: '{"max_tokens":4096,"messages":[{"role":"user","content":"\nCurrent Task:
|
||||
This is a tool-calling compliance test. In your next assistant turn, emit exactly
|
||||
3 tool calls in the same response (parallel tool calls), in this order: 1) parallel_local_search_one(query=''latest
|
||||
OpenAI model release notes''), 2) parallel_local_search_two(query=''latest Anthropic
|
||||
model release notes''), 3) parallel_local_search_three(query=''latest Gemini
|
||||
model release notes''). Do not call any other tools and do not answer before
|
||||
those 3 tool calls are emitted. After the tool results return, provide a one
|
||||
paragraph summary.\n\nThis is the expected criteria for your final answer: A
|
||||
one sentence summary of both tool outputs\nyou MUST return the actual complete
|
||||
content as the final answer, not a summary."}],"model":"claude-sonnet-4-6","stop_sequences":["\nObservation:"],"stream":false,"system":"You
|
||||
are Parallel Tool Agent. You follow tool instructions precisely.\nYour personal
|
||||
goal is: Use both tools exactly as instructed","tools":[{"name":"parallel_local_search_one","description":"Local
|
||||
search tool #1 for concurrency testing.","input_schema":{"properties":{"query":{"description":"Search
|
||||
query","title":"Query","type":"string"}},"required":["query"],"type":"object","additionalProperties":false}},{"name":"parallel_local_search_two","description":"Local
|
||||
search tool #2 for concurrency testing.","input_schema":{"properties":{"query":{"description":"Search
|
||||
query","title":"Query","type":"string"}},"required":["query"],"type":"object","additionalProperties":false}},{"name":"parallel_local_search_three","description":"Local
|
||||
search tool #3 for concurrency testing.","input_schema":{"properties":{"query":{"description":"Search
|
||||
query","title":"Query","type":"string"}},"required":["query"],"type":"object","additionalProperties":false}}]}'
|
||||
headers:
|
||||
User-Agent:
|
||||
- X-USER-AGENT-XXX
|
||||
accept:
|
||||
- application/json
|
||||
accept-encoding:
|
||||
- ACCEPT-ENCODING-XXX
|
||||
anthropic-version:
|
||||
- '2023-06-01'
|
||||
connection:
|
||||
- keep-alive
|
||||
content-length:
|
||||
- '1820'
|
||||
content-type:
|
||||
- application/json
|
||||
host:
|
||||
- api.anthropic.com
|
||||
x-api-key:
|
||||
- X-API-KEY-XXX
|
||||
x-stainless-arch:
|
||||
- X-STAINLESS-ARCH-XXX
|
||||
x-stainless-async:
|
||||
- 'false'
|
||||
x-stainless-lang:
|
||||
- python
|
||||
x-stainless-os:
|
||||
- X-STAINLESS-OS-XXX
|
||||
x-stainless-package-version:
|
||||
- 0.73.0
|
||||
x-stainless-retry-count:
|
||||
- '0'
|
||||
x-stainless-runtime:
|
||||
- CPython
|
||||
x-stainless-runtime-version:
|
||||
- 3.13.3
|
||||
x-stainless-timeout:
|
||||
- NOT_GIVEN
|
||||
method: POST
|
||||
uri: https://api.anthropic.com/v1/messages
|
||||
response:
|
||||
body:
|
||||
string: '{"model":"claude-sonnet-4-6","id":"msg_01RJ4CphwpmkmsJFJjeCNvXz","type":"message","role":"assistant","content":[{"type":"text","text":"I''ll
|
||||
execute all 3 parallel tool calls simultaneously right away!"},{"type":"tool_use","id":"toolu_01YWY3cSomRuv4USmq55Prk3","name":"parallel_local_search_one","input":{"query":"latest
|
||||
OpenAI model release notes"},"caller":{"type":"direct"}},{"type":"tool_use","id":"toolu_01Aaqj3LMXksE1nB3pscRhV5","name":"parallel_local_search_two","input":{"query":"latest
|
||||
Anthropic model release notes"},"caller":{"type":"direct"}},{"type":"tool_use","id":"toolu_01AcYxQvy8aYmAoUg9zx9qfq","name":"parallel_local_search_three","input":{"query":"latest
|
||||
Gemini model release notes"},"caller":{"type":"direct"}}],"stop_reason":"tool_use","stop_sequence":null,"usage":{"input_tokens":951,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":170,"service_tier":"standard","inference_geo":"global"}}'
|
||||
headers:
|
||||
CF-RAY:
|
||||
- CF-RAY-XXX
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Security-Policy:
|
||||
- CSP-FILTERED
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Wed, 18 Feb 2026 23:54:51 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
X-Robots-Tag:
|
||||
- none
|
||||
anthropic-organization-id:
|
||||
- ANTHROPIC-ORGANIZATION-ID-XXX
|
||||
anthropic-ratelimit-input-tokens-limit:
|
||||
- ANTHROPIC-RATELIMIT-INPUT-TOKENS-LIMIT-XXX
|
||||
anthropic-ratelimit-input-tokens-remaining:
|
||||
- ANTHROPIC-RATELIMIT-INPUT-TOKENS-REMAINING-XXX
|
||||
anthropic-ratelimit-input-tokens-reset:
|
||||
- ANTHROPIC-RATELIMIT-INPUT-TOKENS-RESET-XXX
|
||||
anthropic-ratelimit-output-tokens-limit:
|
||||
- ANTHROPIC-RATELIMIT-OUTPUT-TOKENS-LIMIT-XXX
|
||||
anthropic-ratelimit-output-tokens-remaining:
|
||||
- ANTHROPIC-RATELIMIT-OUTPUT-TOKENS-REMAINING-XXX
|
||||
anthropic-ratelimit-output-tokens-reset:
|
||||
- ANTHROPIC-RATELIMIT-OUTPUT-TOKENS-RESET-XXX
|
||||
anthropic-ratelimit-requests-limit:
|
||||
- '20000'
|
||||
anthropic-ratelimit-requests-remaining:
|
||||
- '19999'
|
||||
anthropic-ratelimit-requests-reset:
|
||||
- '2026-02-18T23:54:49Z'
|
||||
anthropic-ratelimit-tokens-limit:
|
||||
- ANTHROPIC-RATELIMIT-TOKENS-LIMIT-XXX
|
||||
anthropic-ratelimit-tokens-remaining:
|
||||
- ANTHROPIC-RATELIMIT-TOKENS-REMAINING-XXX
|
||||
anthropic-ratelimit-tokens-reset:
|
||||
- ANTHROPIC-RATELIMIT-TOKENS-RESET-XXX
|
||||
cf-cache-status:
|
||||
- DYNAMIC
|
||||
request-id:
|
||||
- REQUEST-ID-XXX
|
||||
strict-transport-security:
|
||||
- STS-XXX
|
||||
x-envoy-upstream-service-time:
|
||||
- '1967'
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: '{"max_tokens":4096,"messages":[{"role":"user","content":"\nCurrent Task:
|
||||
This is a tool-calling compliance test. In your next assistant turn, emit exactly
|
||||
3 tool calls in the same response (parallel tool calls), in this order: 1) parallel_local_search_one(query=''latest
|
||||
OpenAI model release notes''), 2) parallel_local_search_two(query=''latest Anthropic
|
||||
model release notes''), 3) parallel_local_search_three(query=''latest Gemini
|
||||
model release notes''). Do not call any other tools and do not answer before
|
||||
those 3 tool calls are emitted. After the tool results return, provide a one
|
||||
paragraph summary.\n\nThis is the expected criteria for your final answer: A
|
||||
one sentence summary of both tool outputs\nyou MUST return the actual complete
|
||||
content as the final answer, not a summary."},{"role":"assistant","content":[{"type":"tool_use","id":"toolu_01YWY3cSomRuv4USmq55Prk3","name":"parallel_local_search_one","input":{"query":"latest
|
||||
OpenAI model release notes"}},{"type":"tool_use","id":"toolu_01Aaqj3LMXksE1nB3pscRhV5","name":"parallel_local_search_two","input":{"query":"latest
|
||||
Anthropic model release notes"}},{"type":"tool_use","id":"toolu_01AcYxQvy8aYmAoUg9zx9qfq","name":"parallel_local_search_three","input":{"query":"latest
|
||||
Gemini model release notes"}}]},{"role":"user","content":[{"type":"tool_result","tool_use_id":"toolu_01YWY3cSomRuv4USmq55Prk3","content":"[one]
|
||||
latest OpenAI model release notes"},{"type":"tool_result","tool_use_id":"toolu_01Aaqj3LMXksE1nB3pscRhV5","content":"[two]
|
||||
latest Anthropic model release notes"},{"type":"tool_result","tool_use_id":"toolu_01AcYxQvy8aYmAoUg9zx9qfq","content":"[three]
|
||||
latest Gemini model release notes"}]},{"role":"user","content":"Analyze the
|
||||
tool result. If requirements are met, provide the Final Answer. Otherwise, call
|
||||
the next tool. Deliver only the answer without meta-commentary."}],"model":"claude-sonnet-4-6","stop_sequences":["\nObservation:"],"stream":false,"system":"You
|
||||
are Parallel Tool Agent. You follow tool instructions precisely.\nYour personal
|
||||
goal is: Use both tools exactly as instructed","tools":[{"name":"parallel_local_search_one","description":"Local
|
||||
search tool #1 for concurrency testing.","input_schema":{"properties":{"query":{"description":"Search
|
||||
query","title":"Query","type":"string"}},"required":["query"],"type":"object","additionalProperties":false}},{"name":"parallel_local_search_two","description":"Local
|
||||
search tool #2 for concurrency testing.","input_schema":{"properties":{"query":{"description":"Search
|
||||
query","title":"Query","type":"string"}},"required":["query"],"type":"object","additionalProperties":false}},{"name":"parallel_local_search_three","description":"Local
|
||||
search tool #3 for concurrency testing.","input_schema":{"properties":{"query":{"description":"Search
|
||||
query","title":"Query","type":"string"}},"required":["query"],"type":"object","additionalProperties":false}}]}'
|
||||
headers:
|
||||
User-Agent:
|
||||
- X-USER-AGENT-XXX
|
||||
accept:
|
||||
- application/json
|
||||
accept-encoding:
|
||||
- ACCEPT-ENCODING-XXX
|
||||
anthropic-version:
|
||||
- '2023-06-01'
|
||||
connection:
|
||||
- keep-alive
|
||||
content-length:
|
||||
- '2882'
|
||||
content-type:
|
||||
- application/json
|
||||
host:
|
||||
- api.anthropic.com
|
||||
x-api-key:
|
||||
- X-API-KEY-XXX
|
||||
x-stainless-arch:
|
||||
- X-STAINLESS-ARCH-XXX
|
||||
x-stainless-async:
|
||||
- 'false'
|
||||
x-stainless-lang:
|
||||
- python
|
||||
x-stainless-os:
|
||||
- X-STAINLESS-OS-XXX
|
||||
x-stainless-package-version:
|
||||
- 0.73.0
|
||||
x-stainless-retry-count:
|
||||
- '0'
|
||||
x-stainless-runtime:
|
||||
- CPython
|
||||
x-stainless-runtime-version:
|
||||
- 3.13.3
|
||||
x-stainless-timeout:
|
||||
- NOT_GIVEN
|
||||
method: POST
|
||||
uri: https://api.anthropic.com/v1/messages
|
||||
response:
|
||||
body:
|
||||
string: "{\"model\":\"claude-sonnet-4-6\",\"id\":\"msg_0143MHUne1az3Tt69EoLjyZd\",\"type\":\"message\",\"role\":\"assistant\",\"content\":[{\"type\":\"text\",\"text\":\"Here
|
||||
is the complete content returned from all three tool calls:\\n\\n- **parallel_local_search_one**
|
||||
result: `[one] latest OpenAI model release notes`\\n- **parallel_local_search_two**
|
||||
result: `[two] latest Anthropic model release notes`\\n- **parallel_local_search_three**
|
||||
result: `[three] latest Gemini model release notes`\\n\\nAll three parallel
|
||||
tool calls were executed successfully in the same response turn, returning
|
||||
their respective outputs: the first tool searched for the latest OpenAI model
|
||||
release notes, the second tool searched for the latest Anthropic model release
|
||||
notes, and the third tool searched for the latest Gemini model release notes
|
||||
\u2014 confirming that all search queries were dispatched concurrently and
|
||||
their results retrieved as expected.\"}],\"stop_reason\":\"end_turn\",\"stop_sequence\":null,\"usage\":{\"input_tokens\":1272,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"cache_creation\":{\"ephemeral_5m_input_tokens\":0,\"ephemeral_1h_input_tokens\":0},\"output_tokens\":172,\"service_tier\":\"standard\",\"inference_geo\":\"global\"}}"
|
||||
headers:
|
||||
CF-RAY:
|
||||
- CF-RAY-XXX
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Security-Policy:
|
||||
- CSP-FILTERED
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Wed, 18 Feb 2026 23:54:55 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
X-Robots-Tag:
|
||||
- none
|
||||
anthropic-organization-id:
|
||||
- ANTHROPIC-ORGANIZATION-ID-XXX
|
||||
anthropic-ratelimit-input-tokens-limit:
|
||||
- ANTHROPIC-RATELIMIT-INPUT-TOKENS-LIMIT-XXX
|
||||
anthropic-ratelimit-input-tokens-remaining:
|
||||
- ANTHROPIC-RATELIMIT-INPUT-TOKENS-REMAINING-XXX
|
||||
anthropic-ratelimit-input-tokens-reset:
|
||||
- ANTHROPIC-RATELIMIT-INPUT-TOKENS-RESET-XXX
|
||||
anthropic-ratelimit-output-tokens-limit:
|
||||
- ANTHROPIC-RATELIMIT-OUTPUT-TOKENS-LIMIT-XXX
|
||||
anthropic-ratelimit-output-tokens-remaining:
|
||||
- ANTHROPIC-RATELIMIT-OUTPUT-TOKENS-REMAINING-XXX
|
||||
anthropic-ratelimit-output-tokens-reset:
|
||||
- ANTHROPIC-RATELIMIT-OUTPUT-TOKENS-RESET-XXX
|
||||
anthropic-ratelimit-requests-limit:
|
||||
- '20000'
|
||||
anthropic-ratelimit-requests-remaining:
|
||||
- '19999'
|
||||
anthropic-ratelimit-requests-reset:
|
||||
- '2026-02-18T23:54:52Z'
|
||||
anthropic-ratelimit-tokens-limit:
|
||||
- ANTHROPIC-RATELIMIT-TOKENS-LIMIT-XXX
|
||||
anthropic-ratelimit-tokens-remaining:
|
||||
- ANTHROPIC-RATELIMIT-TOKENS-REMAINING-XXX
|
||||
anthropic-ratelimit-tokens-reset:
|
||||
- ANTHROPIC-RATELIMIT-TOKENS-RESET-XXX
|
||||
cf-cache-status:
|
||||
- DYNAMIC
|
||||
request-id:
|
||||
- REQUEST-ID-XXX
|
||||
strict-transport-security:
|
||||
- STS-XXX
|
||||
x-envoy-upstream-service-time:
|
||||
- '3144'
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
version: 1
|
||||
@@ -5,20 +5,19 @@ interactions:
|
||||
calculations"}, {"role": "user", "content": "\nCurrent Task: Calculate what
|
||||
is 15 * 8\n\nThis is the expected criteria for your final answer: The result
|
||||
of the calculation\nyou MUST return the actual complete content as the final
|
||||
answer, not a summary.\n\nThis is VERY important to you, your job depends on
|
||||
it!"}], "stream": false, "stop": ["\nObservation:"], "tool_choice": "auto",
|
||||
"tools": [{"function": {"name": "calculator", "description": "Perform mathematical
|
||||
calculations. Use this for any math operations.", "parameters": {"properties":
|
||||
{"expression": {"description": "Mathematical expression to evaluate", "title":
|
||||
"Expression", "type": "string"}}, "required": ["expression"], "type": "object"}},
|
||||
"type": "function"}]}'
|
||||
answer, not a summary."}], "stream": false, "tool_choice": "auto", "tools":
|
||||
[{"function": {"name": "calculator", "description": "Perform mathematical calculations.
|
||||
Use this for any math operations.", "parameters": {"properties": {"expression":
|
||||
{"description": "Mathematical expression to evaluate", "title": "Expression",
|
||||
"type": "string"}}, "required": ["expression"], "type": "object", "additionalProperties":
|
||||
false}}, "type": "function"}]}'
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '883'
|
||||
- '828'
|
||||
Content-Type:
|
||||
- application/json
|
||||
User-Agent:
|
||||
@@ -32,20 +31,20 @@ interactions:
|
||||
x-ms-client-request-id:
|
||||
- X-MS-CLIENT-REQUEST-ID-XXX
|
||||
method: POST
|
||||
uri: https://fake-azure-endpoint.openai.azure.com/openai/deployments/gpt-4o-mini/chat/completions?api-version=2024-12-01-preview
|
||||
uri: https://fake-azure-endpoint.openai.azure.com/openai/deployments/gpt-5-nano/chat/completions?api-version=2024-12-01-preview
|
||||
response:
|
||||
body:
|
||||
string: '{"choices":[{"content_filter_results":{},"finish_reason":"tool_calls","index":0,"logprobs":null,"message":{"annotations":[],"content":null,"refusal":null,"role":"assistant","tool_calls":[{"function":{"arguments":"{\"expression\":\"15
|
||||
* 8\"}","name":"calculator"},"id":"call_cJWzKh5LdBpY3Sk8GATS3eRe","type":"function"}]}}],"created":1769122114,"id":"chatcmpl-D0xlavS0V3m00B9Fsjyv39xQWUGFV","model":"gpt-4o-mini-2024-07-18","object":"chat.completion","prompt_filter_results":[{"prompt_index":0,"content_filter_results":{"hate":{"filtered":false,"severity":"safe"},"jailbreak":{"filtered":false,"detected":false},"self_harm":{"filtered":false,"severity":"safe"},"sexual":{"filtered":false,"severity":"safe"},"violence":{"filtered":false,"severity":"safe"}}}],"system_fingerprint":"fp_f97eff32c5","usage":{"completion_tokens":18,"completion_tokens_details":{"accepted_prediction_tokens":0,"audio_tokens":0,"reasoning_tokens":0,"rejected_prediction_tokens":0},"prompt_tokens":137,"prompt_tokens_details":{"audio_tokens":0,"cached_tokens":0},"total_tokens":155}}
|
||||
* 8\"}","name":"calculator"},"id":"call_Cow46pNllpDx0pxUgZFeqlh1","type":"function"}]}}],"created":1771459544,"id":"chatcmpl-DAlq4osCP9ABJ1HyXFBoYWylMg0bi","model":"gpt-5-nano-2025-08-07","object":"chat.completion","prompt_filter_results":[{"prompt_index":0,"content_filter_results":{"hate":{"filtered":false,"severity":"safe"},"jailbreak":{"filtered":false,"detected":false},"self_harm":{"filtered":false,"severity":"safe"},"sexual":{"filtered":false,"severity":"safe"},"violence":{"filtered":false,"severity":"safe"}}}],"system_fingerprint":null,"usage":{"completion_tokens":219,"completion_tokens_details":{"accepted_prediction_tokens":0,"audio_tokens":0,"reasoning_tokens":192,"rejected_prediction_tokens":0},"prompt_tokens":208,"prompt_tokens_details":{"audio_tokens":0,"cached_tokens":0},"total_tokens":427}}
|
||||
|
||||
'
|
||||
headers:
|
||||
Content-Length:
|
||||
- '1058'
|
||||
- '1049'
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Thu, 22 Jan 2026 22:48:34 GMT
|
||||
- Thu, 19 Feb 2026 00:05:45 GMT
|
||||
Strict-Transport-Security:
|
||||
- STS-XXX
|
||||
apim-request-id:
|
||||
@@ -59,7 +58,7 @@ interactions:
|
||||
x-ms-client-request-id:
|
||||
- X-MS-CLIENT-REQUEST-ID-XXX
|
||||
x-ms-deployment-name:
|
||||
- gpt-4o-mini
|
||||
- gpt-5-nano
|
||||
x-ms-rai-invoked:
|
||||
- 'true'
|
||||
x-ms-region:
|
||||
@@ -83,26 +82,25 @@ interactions:
|
||||
calculations"}, {"role": "user", "content": "\nCurrent Task: Calculate what
|
||||
is 15 * 8\n\nThis is the expected criteria for your final answer: The result
|
||||
of the calculation\nyou MUST return the actual complete content as the final
|
||||
answer, not a summary.\n\nThis is VERY important to you, your job depends on
|
||||
it!"}, {"role": "assistant", "content": "", "tool_calls": [{"id": "call_cJWzKh5LdBpY3Sk8GATS3eRe",
|
||||
"type": "function", "function": {"name": "calculator", "arguments": "{\"expression\":\"15
|
||||
* 8\"}"}}]}, {"role": "tool", "tool_call_id": "call_cJWzKh5LdBpY3Sk8GATS3eRe",
|
||||
"content": "The result of 15 * 8 is 120"}, {"role": "user", "content": "Analyze
|
||||
the tool result. If requirements are met, provide the Final Answer. Otherwise,
|
||||
call the next tool. Deliver only the answer without meta-commentary."}], "stream":
|
||||
false, "stop": ["\nObservation:"], "tool_choice": "auto", "tools": [{"function":
|
||||
{"name": "calculator", "description": "Perform mathematical calculations. Use
|
||||
this for any math operations.", "parameters": {"properties": {"expression":
|
||||
{"description": "Mathematical expression to evaluate", "title": "Expression",
|
||||
"type": "string"}}, "required": ["expression"], "type": "object"}}, "type":
|
||||
"function"}]}'
|
||||
answer, not a summary."}, {"role": "assistant", "content": "", "tool_calls":
|
||||
[{"id": "call_Cow46pNllpDx0pxUgZFeqlh1", "type": "function", "function": {"name":
|
||||
"calculator", "arguments": "{\"expression\":\"15 * 8\"}"}}]}, {"role": "tool",
|
||||
"tool_call_id": "call_Cow46pNllpDx0pxUgZFeqlh1", "content": "The result of 15
|
||||
* 8 is 120"}, {"role": "user", "content": "Analyze the tool result. If requirements
|
||||
are met, provide the Final Answer. Otherwise, call the next tool. Deliver only
|
||||
the answer without meta-commentary."}], "stream": false, "tool_choice": "auto",
|
||||
"tools": [{"function": {"name": "calculator", "description": "Perform mathematical
|
||||
calculations. Use this for any math operations.", "parameters": {"properties":
|
||||
{"expression": {"description": "Mathematical expression to evaluate", "title":
|
||||
"Expression", "type": "string"}}, "required": ["expression"], "type": "object",
|
||||
"additionalProperties": false}}, "type": "function"}]}'
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '1375'
|
||||
- '1320'
|
||||
Content-Type:
|
||||
- application/json
|
||||
User-Agent:
|
||||
@@ -116,20 +114,19 @@ interactions:
|
||||
x-ms-client-request-id:
|
||||
- X-MS-CLIENT-REQUEST-ID-XXX
|
||||
method: POST
|
||||
uri: https://fake-azure-endpoint.openai.azure.com/openai/deployments/gpt-4o-mini/chat/completions?api-version=2024-12-01-preview
|
||||
uri: https://fake-azure-endpoint.openai.azure.com/openai/deployments/gpt-5-nano/chat/completions?api-version=2024-12-01-preview
|
||||
response:
|
||||
body:
|
||||
string: '{"choices":[{"content_filter_results":{"hate":{"filtered":false,"severity":"safe"},"protected_material_code":{"filtered":false,"detected":false},"protected_material_text":{"filtered":false,"detected":false},"self_harm":{"filtered":false,"severity":"safe"},"sexual":{"filtered":false,"severity":"safe"},"violence":{"filtered":false,"severity":"safe"}},"finish_reason":"stop","index":0,"logprobs":null,"message":{"annotations":[],"content":"The
|
||||
result of the calculation is 120.","refusal":null,"role":"assistant"}}],"created":1769122115,"id":"chatcmpl-D0xlbUNVA7RVkn0GsuBGoNhgQTtac","model":"gpt-4o-mini-2024-07-18","object":"chat.completion","prompt_filter_results":[{"prompt_index":0,"content_filter_results":{"hate":{"filtered":false,"severity":"safe"},"jailbreak":{"filtered":false,"detected":false},"self_harm":{"filtered":false,"severity":"safe"},"sexual":{"filtered":false,"severity":"safe"},"violence":{"filtered":false,"severity":"safe"}}}],"system_fingerprint":"fp_f97eff32c5","usage":{"completion_tokens":11,"completion_tokens_details":{"accepted_prediction_tokens":0,"audio_tokens":0,"reasoning_tokens":0,"rejected_prediction_tokens":0},"prompt_tokens":207,"prompt_tokens_details":{"audio_tokens":0,"cached_tokens":0},"total_tokens":218}}
|
||||
string: '{"choices":[{"content_filter_results":{"hate":{"filtered":false,"severity":"safe"},"protected_material_code":{"filtered":false,"detected":false},"protected_material_text":{"filtered":false,"detected":false},"self_harm":{"filtered":false,"severity":"safe"},"sexual":{"filtered":false,"severity":"safe"},"violence":{"filtered":false,"severity":"safe"}},"finish_reason":"stop","index":0,"logprobs":null,"message":{"annotations":[],"content":"120","refusal":null,"role":"assistant"}}],"created":1771459547,"id":"chatcmpl-DAlq7zJimnIMoXieNww8jY5f2pIPd","model":"gpt-5-nano-2025-08-07","object":"chat.completion","prompt_filter_results":[{"prompt_index":0,"content_filter_results":{"hate":{"filtered":false,"severity":"safe"},"jailbreak":{"filtered":false,"detected":false},"self_harm":{"filtered":false,"severity":"safe"},"sexual":{"filtered":false,"severity":"safe"},"violence":{"filtered":false,"severity":"safe"}}}],"system_fingerprint":null,"usage":{"completion_tokens":203,"completion_tokens_details":{"accepted_prediction_tokens":0,"audio_tokens":0,"reasoning_tokens":192,"rejected_prediction_tokens":0},"prompt_tokens":284,"prompt_tokens_details":{"audio_tokens":0,"cached_tokens":0},"total_tokens":487}}
|
||||
|
||||
'
|
||||
headers:
|
||||
Content-Length:
|
||||
- '1250'
|
||||
- '1207'
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Thu, 22 Jan 2026 22:48:34 GMT
|
||||
- Thu, 19 Feb 2026 00:05:49 GMT
|
||||
Strict-Transport-Security:
|
||||
- STS-XXX
|
||||
apim-request-id:
|
||||
@@ -143,7 +140,7 @@ interactions:
|
||||
x-ms-client-request-id:
|
||||
- X-MS-CLIENT-REQUEST-ID-XXX
|
||||
x-ms-deployment-name:
|
||||
- gpt-4o-mini
|
||||
- gpt-5-nano
|
||||
x-ms-rai-invoked:
|
||||
- 'true'
|
||||
x-ms-region:
|
||||
|
||||
@@ -0,0 +1,198 @@
|
||||
interactions:
|
||||
- request:
|
||||
body: '{"messages": [{"role": "system", "content": "You are Parallel Tool Agent.
|
||||
You follow tool instructions precisely.\nYour personal goal is: Use both tools
|
||||
exactly as instructed"}, {"role": "user", "content": "\nCurrent Task: This is
|
||||
a tool-calling compliance test. In your next assistant turn, emit exactly 3
|
||||
tool calls in the same response (parallel tool calls), in this order: 1) parallel_local_search_one(query=''latest
|
||||
OpenAI model release notes''), 2) parallel_local_search_two(query=''latest Anthropic
|
||||
model release notes''), 3) parallel_local_search_three(query=''latest Gemini
|
||||
model release notes''). Do not call any other tools and do not answer before
|
||||
those 3 tool calls are emitted. After the tool results return, provide a one
|
||||
paragraph summary."}], "stream": false, "tool_choice": "auto", "tools": [{"function":
|
||||
{"name": "parallel_local_search_one", "description": "Local search tool #1 for
|
||||
concurrency testing.", "parameters": {"properties": {"query": {"description":
|
||||
"Search query", "title": "Query", "type": "string"}}, "required": ["query"],
|
||||
"type": "object", "additionalProperties": false}}, "type": "function"}, {"function":
|
||||
{"name": "parallel_local_search_two", "description": "Local search tool #2 for
|
||||
concurrency testing.", "parameters": {"properties": {"query": {"description":
|
||||
"Search query", "title": "Query", "type": "string"}}, "required": ["query"],
|
||||
"type": "object", "additionalProperties": false}}, "type": "function"}, {"function":
|
||||
{"name": "parallel_local_search_three", "description": "Local search tool #3
|
||||
for concurrency testing.", "parameters": {"properties": {"query": {"description":
|
||||
"Search query", "title": "Query", "type": "string"}}, "required": ["query"],
|
||||
"type": "object", "additionalProperties": false}}, "type": "function"}]}'
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '1763'
|
||||
Content-Type:
|
||||
- application/json
|
||||
User-Agent:
|
||||
- X-USER-AGENT-XXX
|
||||
accept-encoding:
|
||||
- ACCEPT-ENCODING-XXX
|
||||
api-key:
|
||||
- X-API-KEY-XXX
|
||||
authorization:
|
||||
- AUTHORIZATION-XXX
|
||||
x-ms-client-request-id:
|
||||
- X-MS-CLIENT-REQUEST-ID-XXX
|
||||
method: POST
|
||||
uri: https://fake-azure-endpoint.openai.azure.com/openai/deployments/gpt-5-nano/chat/completions?api-version=2024-12-01-preview
|
||||
response:
|
||||
body:
|
||||
string: '{"choices":[{"content_filter_results":{},"finish_reason":"tool_calls","index":0,"logprobs":null,"message":{"annotations":[],"content":null,"refusal":null,"role":"assistant","tool_calls":[{"function":{"arguments":"{\"query\":
|
||||
\"latest OpenAI model release notes\"}","name":"parallel_local_search_one"},"id":"call_emQmocGydKuxvESfQopNngdm","type":"function"},{"function":{"arguments":"{\"query\":
|
||||
\"latest Anthropic model release notes\"}","name":"parallel_local_search_two"},"id":"call_eNpK9WUYFCX2ZEUPhYCKvdMs","type":"function"},{"function":{"arguments":"{\"query\":
|
||||
\"latest Gemini model release notes\"}","name":"parallel_local_search_three"},"id":"call_Wdtl6jFxGehSUMn5I1O4Mrdx","type":"function"}]}}],"created":1771459550,"id":"chatcmpl-DAlqAyJGnQKDkNCaTcjU2T8BeJaXM","model":"gpt-5-nano-2025-08-07","object":"chat.completion","prompt_filter_results":[{"prompt_index":0,"content_filter_results":{"hate":{"filtered":false,"severity":"safe"},"jailbreak":{"filtered":false,"detected":false},"self_harm":{"filtered":false,"severity":"safe"},"sexual":{"filtered":false,"severity":"safe"},"violence":{"filtered":false,"severity":"safe"}}}],"system_fingerprint":null,"usage":{"completion_tokens":666,"completion_tokens_details":{"accepted_prediction_tokens":0,"audio_tokens":0,"reasoning_tokens":576,"rejected_prediction_tokens":0},"prompt_tokens":343,"prompt_tokens_details":{"audio_tokens":0,"cached_tokens":0},"total_tokens":1009}}
|
||||
|
||||
'
|
||||
headers:
|
||||
Content-Length:
|
||||
- '1433'
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Thu, 19 Feb 2026 00:05:55 GMT
|
||||
Strict-Transport-Security:
|
||||
- STS-XXX
|
||||
apim-request-id:
|
||||
- APIM-REQUEST-ID-XXX
|
||||
azureml-model-session:
|
||||
- AZUREML-MODEL-SESSION-XXX
|
||||
x-accel-buffering:
|
||||
- 'no'
|
||||
x-content-type-options:
|
||||
- X-CONTENT-TYPE-XXX
|
||||
x-ms-client-request-id:
|
||||
- X-MS-CLIENT-REQUEST-ID-XXX
|
||||
x-ms-deployment-name:
|
||||
- gpt-5-nano
|
||||
x-ms-rai-invoked:
|
||||
- 'true'
|
||||
x-ms-region:
|
||||
- X-MS-REGION-XXX
|
||||
x-ratelimit-limit-requests:
|
||||
- X-RATELIMIT-LIMIT-REQUESTS-XXX
|
||||
x-ratelimit-limit-tokens:
|
||||
- X-RATELIMIT-LIMIT-TOKENS-XXX
|
||||
x-ratelimit-remaining-requests:
|
||||
- X-RATELIMIT-REMAINING-REQUESTS-XXX
|
||||
x-ratelimit-remaining-tokens:
|
||||
- X-RATELIMIT-REMAINING-TOKENS-XXX
|
||||
x-request-id:
|
||||
- X-REQUEST-ID-XXX
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: '{"messages": [{"role": "system", "content": "You are Parallel Tool Agent.
|
||||
You follow tool instructions precisely.\nYour personal goal is: Use both tools
|
||||
exactly as instructed"}, {"role": "user", "content": "\nCurrent Task: This is
|
||||
a tool-calling compliance test. In your next assistant turn, emit exactly 3
|
||||
tool calls in the same response (parallel tool calls), in this order: 1) parallel_local_search_one(query=''latest
|
||||
OpenAI model release notes''), 2) parallel_local_search_two(query=''latest Anthropic
|
||||
model release notes''), 3) parallel_local_search_three(query=''latest Gemini
|
||||
model release notes''). Do not call any other tools and do not answer before
|
||||
those 3 tool calls are emitted. After the tool results return, provide a one
|
||||
paragraph summary."}, {"role": "assistant", "content": "", "tool_calls": [{"id":
|
||||
"call_emQmocGydKuxvESfQopNngdm", "type": "function", "function": {"name": "parallel_local_search_one",
|
||||
"arguments": "{\"query\": \"latest OpenAI model release notes\"}"}}, {"id":
|
||||
"call_eNpK9WUYFCX2ZEUPhYCKvdMs", "type": "function", "function": {"name": "parallel_local_search_two",
|
||||
"arguments": "{\"query\": \"latest Anthropic model release notes\"}"}}, {"id":
|
||||
"call_Wdtl6jFxGehSUMn5I1O4Mrdx", "type": "function", "function": {"name": "parallel_local_search_three",
|
||||
"arguments": "{\"query\": \"latest Gemini model release notes\"}"}}]}, {"role":
|
||||
"tool", "tool_call_id": "call_emQmocGydKuxvESfQopNngdm", "content": "[one] latest
|
||||
OpenAI model release notes"}, {"role": "tool", "tool_call_id": "call_eNpK9WUYFCX2ZEUPhYCKvdMs",
|
||||
"content": "[two] latest Anthropic model release notes"}, {"role": "tool", "tool_call_id":
|
||||
"call_Wdtl6jFxGehSUMn5I1O4Mrdx", "content": "[three] latest Gemini model release
|
||||
notes"}], "stream": false, "tool_choice": "auto", "tools": [{"function": {"name":
|
||||
"parallel_local_search_one", "description": "Local search tool #1 for concurrency
|
||||
testing.", "parameters": {"properties": {"query": {"description": "Search query",
|
||||
"title": "Query", "type": "string"}}, "required": ["query"], "type": "object",
|
||||
"additionalProperties": false}}, "type": "function"}, {"function": {"name":
|
||||
"parallel_local_search_two", "description": "Local search tool #2 for concurrency
|
||||
testing.", "parameters": {"properties": {"query": {"description": "Search query",
|
||||
"title": "Query", "type": "string"}}, "required": ["query"], "type": "object",
|
||||
"additionalProperties": false}}, "type": "function"}, {"function": {"name":
|
||||
"parallel_local_search_three", "description": "Local search tool #3 for concurrency
|
||||
testing.", "parameters": {"properties": {"query": {"description": "Search query",
|
||||
"title": "Query", "type": "string"}}, "required": ["query"], "type": "object",
|
||||
"additionalProperties": false}}, "type": "function"}]}'
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '2727'
|
||||
Content-Type:
|
||||
- application/json
|
||||
User-Agent:
|
||||
- X-USER-AGENT-XXX
|
||||
accept-encoding:
|
||||
- ACCEPT-ENCODING-XXX
|
||||
api-key:
|
||||
- X-API-KEY-XXX
|
||||
authorization:
|
||||
- AUTHORIZATION-XXX
|
||||
x-ms-client-request-id:
|
||||
- X-MS-CLIENT-REQUEST-ID-XXX
|
||||
method: POST
|
||||
uri: https://fake-azure-endpoint.openai.azure.com/openai/deployments/gpt-5-nano/chat/completions?api-version=2024-12-01-preview
|
||||
response:
|
||||
body:
|
||||
string: '{"choices":[{"content_filter_results":{"hate":{"filtered":false,"severity":"safe"},"protected_material_code":{"filtered":false,"detected":false},"protected_material_text":{"filtered":false,"detected":false},"self_harm":{"filtered":false,"severity":"safe"},"sexual":{"filtered":false,"severity":"safe"},"violence":{"filtered":false,"severity":"safe"}},"finish_reason":"stop","index":0,"logprobs":null,"message":{"annotations":[],"content":"The
|
||||
latest release notes have been published for the OpenAI, Anthropic, and Gemini
|
||||
models, signaling concurrent updates across the leading AI model families.
|
||||
Each set outlines new capabilities and performance improvements, along with
|
||||
changes to APIs, tooling, and deployment guidelines. Users should review the
|
||||
individual notes to understand new features, adjustments to tokenization,
|
||||
latency or throughput, safety and alignment enhancements, pricing or access
|
||||
changes, and any breaking changes or migration steps required to adopt the
|
||||
updated models in existing workflows.","refusal":null,"role":"assistant"}}],"created":1771459556,"id":"chatcmpl-DAlqGKWXfGNlTIbDY9F6oHQp6hbxM","model":"gpt-5-nano-2025-08-07","object":"chat.completion","prompt_filter_results":[{"prompt_index":0,"content_filter_results":{"hate":{"filtered":false,"severity":"safe"},"jailbreak":{"filtered":false,"detected":false},"self_harm":{"filtered":false,"severity":"safe"},"sexual":{"filtered":false,"severity":"safe"},"violence":{"filtered":false,"severity":"safe"}}}],"system_fingerprint":null,"usage":{"completion_tokens":747,"completion_tokens_details":{"accepted_prediction_tokens":0,"audio_tokens":0,"reasoning_tokens":640,"rejected_prediction_tokens":0},"prompt_tokens":467,"prompt_tokens_details":{"audio_tokens":0,"cached_tokens":0},"total_tokens":1214}}
|
||||
|
||||
'
|
||||
headers:
|
||||
Content-Length:
|
||||
- '1778'
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Thu, 19 Feb 2026 00:06:02 GMT
|
||||
Strict-Transport-Security:
|
||||
- STS-XXX
|
||||
apim-request-id:
|
||||
- APIM-REQUEST-ID-XXX
|
||||
azureml-model-session:
|
||||
- AZUREML-MODEL-SESSION-XXX
|
||||
x-accel-buffering:
|
||||
- 'no'
|
||||
x-content-type-options:
|
||||
- X-CONTENT-TYPE-XXX
|
||||
x-ms-client-request-id:
|
||||
- X-MS-CLIENT-REQUEST-ID-XXX
|
||||
x-ms-deployment-name:
|
||||
- gpt-5-nano
|
||||
x-ms-rai-invoked:
|
||||
- 'true'
|
||||
x-ms-region:
|
||||
- X-MS-REGION-XXX
|
||||
x-ratelimit-limit-requests:
|
||||
- X-RATELIMIT-LIMIT-REQUESTS-XXX
|
||||
x-ratelimit-limit-tokens:
|
||||
- X-RATELIMIT-LIMIT-TOKENS-XXX
|
||||
x-ratelimit-remaining-requests:
|
||||
- X-RATELIMIT-REMAINING-REQUESTS-XXX
|
||||
x-ratelimit-remaining-tokens:
|
||||
- X-RATELIMIT-REMAINING-TOKENS-XXX
|
||||
x-request-id:
|
||||
- X-REQUEST-ID-XXX
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
version: 1
|
||||
@@ -0,0 +1,201 @@
|
||||
interactions:
|
||||
- request:
|
||||
body: '{"messages": [{"role": "system", "content": "You are Parallel Tool Agent.
|
||||
You follow tool instructions precisely.\nYour personal goal is: Use both tools
|
||||
exactly as instructed"}, {"role": "user", "content": "\nCurrent Task: This is
|
||||
a tool-calling compliance test. In your next assistant turn, emit exactly 3
|
||||
tool calls in the same response (parallel tool calls), in this order: 1) parallel_local_search_one(query=''latest
|
||||
OpenAI model release notes''), 2) parallel_local_search_two(query=''latest Anthropic
|
||||
model release notes''), 3) parallel_local_search_three(query=''latest Gemini
|
||||
model release notes''). Do not call any other tools and do not answer before
|
||||
those 3 tool calls are emitted. After the tool results return, provide a one
|
||||
paragraph summary.\n\nThis is the expected criteria for your final answer: A
|
||||
one sentence summary of both tool outputs\nyou MUST return the actual complete
|
||||
content as the final answer, not a summary."}], "stream": false, "tool_choice":
|
||||
"auto", "tools": [{"function": {"name": "parallel_local_search_one", "description":
|
||||
"Local search tool #1 for concurrency testing.", "parameters": {"properties":
|
||||
{"query": {"description": "Search query", "title": "Query", "type": "string"}},
|
||||
"required": ["query"], "type": "object", "additionalProperties": false}}, "type":
|
||||
"function"}, {"function": {"name": "parallel_local_search_two", "description":
|
||||
"Local search tool #2 for concurrency testing.", "parameters": {"properties":
|
||||
{"query": {"description": "Search query", "title": "Query", "type": "string"}},
|
||||
"required": ["query"], "type": "object", "additionalProperties": false}}, "type":
|
||||
"function"}, {"function": {"name": "parallel_local_search_three", "description":
|
||||
"Local search tool #3 for concurrency testing.", "parameters": {"properties":
|
||||
{"query": {"description": "Search query", "title": "Query", "type": "string"}},
|
||||
"required": ["query"], "type": "object", "additionalProperties": false}}, "type":
|
||||
"function"}]}'
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '1944'
|
||||
Content-Type:
|
||||
- application/json
|
||||
User-Agent:
|
||||
- X-USER-AGENT-XXX
|
||||
accept-encoding:
|
||||
- ACCEPT-ENCODING-XXX
|
||||
api-key:
|
||||
- X-API-KEY-XXX
|
||||
authorization:
|
||||
- AUTHORIZATION-XXX
|
||||
x-ms-client-request-id:
|
||||
- X-MS-CLIENT-REQUEST-ID-XXX
|
||||
method: POST
|
||||
uri: https://fake-azure-endpoint.openai.azure.com/openai/deployments/gpt-5-nano/chat/completions?api-version=2024-12-01-preview
|
||||
response:
|
||||
body:
|
||||
string: '{"choices":[{"content_filter_results":{},"finish_reason":"tool_calls","index":0,"logprobs":null,"message":{"annotations":[],"content":null,"refusal":null,"role":"assistant","tool_calls":[{"function":{"arguments":"{\"query\":
|
||||
\"latest OpenAI model release notes\"}","name":"parallel_local_search_one"},"id":"call_NEvGoF86nhPQfXRoJd5SOyLd","type":"function"},{"function":{"arguments":"{\"query\":
|
||||
\"latest Anthropic model release notes\"}","name":"parallel_local_search_two"},"id":"call_q8Q2du4gAMQLrGTgWgfwfbDZ","type":"function"},{"function":{"arguments":"{\"query\":
|
||||
\"latest Gemini model release notes\"}","name":"parallel_local_search_three"},"id":"call_yTBal9ofZzuo10j0pWqhHCSj","type":"function"}]}}],"created":1771459563,"id":"chatcmpl-DAlqN7kyC5ACI5Yl1Pj63rOH5HIvI","model":"gpt-5-nano-2025-08-07","object":"chat.completion","prompt_filter_results":[{"prompt_index":0,"content_filter_results":{"hate":{"filtered":false,"severity":"safe"},"jailbreak":{"filtered":false,"detected":false},"self_harm":{"filtered":false,"severity":"safe"},"sexual":{"filtered":false,"severity":"safe"},"violence":{"filtered":false,"severity":"safe"}}}],"system_fingerprint":null,"usage":{"completion_tokens":2457,"completion_tokens_details":{"accepted_prediction_tokens":0,"audio_tokens":0,"reasoning_tokens":2368,"rejected_prediction_tokens":0},"prompt_tokens":378,"prompt_tokens_details":{"audio_tokens":0,"cached_tokens":0},"total_tokens":2835}}
|
||||
|
||||
'
|
||||
headers:
|
||||
Content-Length:
|
||||
- '1435'
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Thu, 19 Feb 2026 00:06:17 GMT
|
||||
Strict-Transport-Security:
|
||||
- STS-XXX
|
||||
apim-request-id:
|
||||
- APIM-REQUEST-ID-XXX
|
||||
azureml-model-session:
|
||||
- AZUREML-MODEL-SESSION-XXX
|
||||
x-accel-buffering:
|
||||
- 'no'
|
||||
x-content-type-options:
|
||||
- X-CONTENT-TYPE-XXX
|
||||
x-ms-client-request-id:
|
||||
- X-MS-CLIENT-REQUEST-ID-XXX
|
||||
x-ms-deployment-name:
|
||||
- gpt-5-nano
|
||||
x-ms-rai-invoked:
|
||||
- 'true'
|
||||
x-ms-region:
|
||||
- X-MS-REGION-XXX
|
||||
x-ratelimit-limit-requests:
|
||||
- X-RATELIMIT-LIMIT-REQUESTS-XXX
|
||||
x-ratelimit-limit-tokens:
|
||||
- X-RATELIMIT-LIMIT-TOKENS-XXX
|
||||
x-ratelimit-remaining-requests:
|
||||
- X-RATELIMIT-REMAINING-REQUESTS-XXX
|
||||
x-ratelimit-remaining-tokens:
|
||||
- X-RATELIMIT-REMAINING-TOKENS-XXX
|
||||
x-request-id:
|
||||
- X-REQUEST-ID-XXX
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: '{"messages": [{"role": "system", "content": "You are Parallel Tool Agent.
|
||||
You follow tool instructions precisely.\nYour personal goal is: Use both tools
|
||||
exactly as instructed"}, {"role": "user", "content": "\nCurrent Task: This is
|
||||
a tool-calling compliance test. In your next assistant turn, emit exactly 3
|
||||
tool calls in the same response (parallel tool calls), in this order: 1) parallel_local_search_one(query=''latest
|
||||
OpenAI model release notes''), 2) parallel_local_search_two(query=''latest Anthropic
|
||||
model release notes''), 3) parallel_local_search_three(query=''latest Gemini
|
||||
model release notes''). Do not call any other tools and do not answer before
|
||||
those 3 tool calls are emitted. After the tool results return, provide a one
|
||||
paragraph summary.\n\nThis is the expected criteria for your final answer: A
|
||||
one sentence summary of both tool outputs\nyou MUST return the actual complete
|
||||
content as the final answer, not a summary."}, {"role": "assistant", "content":
|
||||
"", "tool_calls": [{"id": "call_NEvGoF86nhPQfXRoJd5SOyLd", "type": "function",
|
||||
"function": {"name": "parallel_local_search_one", "arguments": "{\"query\":
|
||||
\"latest OpenAI model release notes\"}"}}, {"id": "call_q8Q2du4gAMQLrGTgWgfwfbDZ",
|
||||
"type": "function", "function": {"name": "parallel_local_search_two", "arguments":
|
||||
"{\"query\": \"latest Anthropic model release notes\"}"}}, {"id": "call_yTBal9ofZzuo10j0pWqhHCSj",
|
||||
"type": "function", "function": {"name": "parallel_local_search_three", "arguments":
|
||||
"{\"query\": \"latest Gemini model release notes\"}"}}]}, {"role": "tool", "tool_call_id":
|
||||
"call_NEvGoF86nhPQfXRoJd5SOyLd", "content": "[one] latest OpenAI model release
|
||||
notes"}, {"role": "tool", "tool_call_id": "call_q8Q2du4gAMQLrGTgWgfwfbDZ", "content":
|
||||
"[two] latest Anthropic model release notes"}, {"role": "tool", "tool_call_id":
|
||||
"call_yTBal9ofZzuo10j0pWqhHCSj", "content": "[three] latest Gemini model release
|
||||
notes"}, {"role": "user", "content": "Analyze the tool result. If requirements
|
||||
are met, provide the Final Answer. Otherwise, call the next tool. Deliver only
|
||||
the answer without meta-commentary."}], "stream": false, "tool_choice": "auto",
|
||||
"tools": [{"function": {"name": "parallel_local_search_one", "description":
|
||||
"Local search tool #1 for concurrency testing.", "parameters": {"properties":
|
||||
{"query": {"description": "Search query", "title": "Query", "type": "string"}},
|
||||
"required": ["query"], "type": "object", "additionalProperties": false}}, "type":
|
||||
"function"}, {"function": {"name": "parallel_local_search_two", "description":
|
||||
"Local search tool #2 for concurrency testing.", "parameters": {"properties":
|
||||
{"query": {"description": "Search query", "title": "Query", "type": "string"}},
|
||||
"required": ["query"], "type": "object", "additionalProperties": false}}, "type":
|
||||
"function"}, {"function": {"name": "parallel_local_search_three", "description":
|
||||
"Local search tool #3 for concurrency testing.", "parameters": {"properties":
|
||||
{"query": {"description": "Search query", "title": "Query", "type": "string"}},
|
||||
"required": ["query"], "type": "object", "additionalProperties": false}}, "type":
|
||||
"function"}]}'
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '3096'
|
||||
Content-Type:
|
||||
- application/json
|
||||
User-Agent:
|
||||
- X-USER-AGENT-XXX
|
||||
accept-encoding:
|
||||
- ACCEPT-ENCODING-XXX
|
||||
api-key:
|
||||
- X-API-KEY-XXX
|
||||
authorization:
|
||||
- AUTHORIZATION-XXX
|
||||
x-ms-client-request-id:
|
||||
- X-MS-CLIENT-REQUEST-ID-XXX
|
||||
method: POST
|
||||
uri: https://fake-azure-endpoint.openai.azure.com/openai/deployments/gpt-5-nano/chat/completions?api-version=2024-12-01-preview
|
||||
response:
|
||||
body:
|
||||
string: '{"choices":[{"content_filter_results":{"hate":{"filtered":false,"severity":"safe"},"protected_material_code":{"filtered":false,"detected":false},"protected_material_text":{"filtered":false,"detected":false},"self_harm":{"filtered":false,"severity":"safe"},"sexual":{"filtered":false,"severity":"safe"},"violence":{"filtered":false,"severity":"safe"}},"finish_reason":"stop","index":0,"logprobs":null,"message":{"annotations":[],"content":"The
|
||||
three tool results indicate the latest release notes are available for OpenAI
|
||||
models, Anthropic models, and Gemini models.","refusal":null,"role":"assistant"}}],"created":1771459579,"id":"chatcmpl-DAlqdRtr8EefmFfazuh4jm7KvVxim","model":"gpt-5-nano-2025-08-07","object":"chat.completion","prompt_filter_results":[{"prompt_index":0,"content_filter_results":{"hate":{"filtered":false,"severity":"safe"},"jailbreak":{"filtered":false,"detected":false},"self_harm":{"filtered":false,"severity":"safe"},"sexual":{"filtered":false,"severity":"safe"},"violence":{"filtered":false,"severity":"safe"}}}],"system_fingerprint":null,"usage":{"completion_tokens":1826,"completion_tokens_details":{"accepted_prediction_tokens":0,"audio_tokens":0,"reasoning_tokens":1792,"rejected_prediction_tokens":0},"prompt_tokens":537,"prompt_tokens_details":{"audio_tokens":0,"cached_tokens":0},"total_tokens":2363}}
|
||||
|
||||
'
|
||||
headers:
|
||||
Content-Length:
|
||||
- '1333'
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Thu, 19 Feb 2026 00:06:31 GMT
|
||||
Strict-Transport-Security:
|
||||
- STS-XXX
|
||||
apim-request-id:
|
||||
- APIM-REQUEST-ID-XXX
|
||||
azureml-model-session:
|
||||
- AZUREML-MODEL-SESSION-XXX
|
||||
x-accel-buffering:
|
||||
- 'no'
|
||||
x-content-type-options:
|
||||
- X-CONTENT-TYPE-XXX
|
||||
x-ms-client-request-id:
|
||||
- X-MS-CLIENT-REQUEST-ID-XXX
|
||||
x-ms-deployment-name:
|
||||
- gpt-5-nano
|
||||
x-ms-rai-invoked:
|
||||
- 'true'
|
||||
x-ms-region:
|
||||
- X-MS-REGION-XXX
|
||||
x-ratelimit-limit-requests:
|
||||
- X-RATELIMIT-LIMIT-REQUESTS-XXX
|
||||
x-ratelimit-limit-tokens:
|
||||
- X-RATELIMIT-LIMIT-TOKENS-XXX
|
||||
x-ratelimit-remaining-requests:
|
||||
- X-RATELIMIT-REMAINING-REQUESTS-XXX
|
||||
x-ratelimit-remaining-tokens:
|
||||
- X-RATELIMIT-REMAINING-TOKENS-XXX
|
||||
x-request-id:
|
||||
- X-REQUEST-ID-XXX
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
version: 1
|
||||
@@ -0,0 +1,63 @@
|
||||
interactions:
|
||||
- request:
|
||||
body: '{"messages": [{"role": "user", "content": [{"text": "\nCurrent Task: This
|
||||
is a tool-calling compliance test. In your next assistant turn, emit exactly
|
||||
3 tool calls in the same response (parallel tool calls), in this order: 1) parallel_local_search_one(query=''latest
|
||||
OpenAI model release notes''), 2) parallel_local_search_two(query=''latest Anthropic
|
||||
model release notes''), 3) parallel_local_search_three(query=''latest Gemini
|
||||
model release notes''). Do not call any other tools and do not answer before
|
||||
those 3 tool calls are emitted. After the tool results return, provide a one
|
||||
paragraph summary."}]}], "inferenceConfig": {"stopSequences": ["\nObservation:"]},
|
||||
"system": [{"text": "You are Parallel Tool Agent. You follow tool instructions
|
||||
precisely.\nYour personal goal is: Use both tools exactly as instructed"}],
|
||||
"toolConfig": {"tools": [{"toolSpec": {"name": "parallel_local_search_one",
|
||||
"description": "Local search tool #1 for concurrency testing.", "inputSchema":
|
||||
{"json": {"properties": {"query": {"description": "Search query", "title": "Query",
|
||||
"type": "string"}}, "required": ["query"], "type": "object", "additionalProperties":
|
||||
false}}}}, {"toolSpec": {"name": "parallel_local_search_two", "description":
|
||||
"Local search tool #2 for concurrency testing.", "inputSchema": {"json": {"properties":
|
||||
{"query": {"description": "Search query", "title": "Query", "type": "string"}},
|
||||
"required": ["query"], "type": "object", "additionalProperties": false}}}},
|
||||
{"toolSpec": {"name": "parallel_local_search_three", "description": "Local search
|
||||
tool #3 for concurrency testing.", "inputSchema": {"json": {"properties": {"query":
|
||||
{"description": "Search query", "title": "Query", "type": "string"}}, "required":
|
||||
["query"], "type": "object", "additionalProperties": false}}}}]}}'
|
||||
headers:
|
||||
Content-Length:
|
||||
- '1773'
|
||||
Content-Type:
|
||||
- !!binary |
|
||||
YXBwbGljYXRpb24vanNvbg==
|
||||
User-Agent:
|
||||
- X-USER-AGENT-XXX
|
||||
amz-sdk-invocation-id:
|
||||
- AMZ-SDK-INVOCATION-ID-XXX
|
||||
amz-sdk-request:
|
||||
- !!binary |
|
||||
YXR0ZW1wdD0x
|
||||
authorization:
|
||||
- AUTHORIZATION-XXX
|
||||
x-amz-date:
|
||||
- X-AMZ-DATE-XXX
|
||||
method: POST
|
||||
uri: https://bedrock-runtime.us-east-1.amazonaws.com/model/anthropic.claude-3-haiku-20240307-v1%3A0/converse
|
||||
response:
|
||||
body:
|
||||
string: '{"message":"The security token included in the request is invalid."}'
|
||||
headers:
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '68'
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Thu, 19 Feb 2026 00:00:08 GMT
|
||||
x-amzn-ErrorType:
|
||||
- UnrecognizedClientException:http://internal.amazon.com/coral/com.amazon.coral.service/
|
||||
x-amzn-RequestId:
|
||||
- X-AMZN-REQUESTID-XXX
|
||||
status:
|
||||
code: 403
|
||||
message: Forbidden
|
||||
version: 1
|
||||
@@ -0,0 +1,226 @@
|
||||
interactions:
|
||||
- request:
|
||||
body: '{"messages": [{"role": "user", "content": [{"text": "\nCurrent Task: This
|
||||
is a tool-calling compliance test. In your next assistant turn, emit exactly
|
||||
3 tool calls in the same response (parallel tool calls), in this order: 1) parallel_local_search_one(query=''latest
|
||||
OpenAI model release notes''), 2) parallel_local_search_two(query=''latest Anthropic
|
||||
model release notes''), 3) parallel_local_search_three(query=''latest Gemini
|
||||
model release notes''). Do not call any other tools and do not answer before
|
||||
those 3 tool calls are emitted. After the tool results return, provide a one
|
||||
paragraph summary.\n\nThis is the expected criteria for your final answer: A
|
||||
one sentence summary of both tool outputs\nyou MUST return the actual complete
|
||||
content as the final answer, not a summary."}]}], "inferenceConfig": {"stopSequences":
|
||||
["\nObservation:"]}, "system": [{"text": "You are Parallel Tool Agent. You follow
|
||||
tool instructions precisely.\nYour personal goal is: Use both tools exactly
|
||||
as instructed"}], "toolConfig": {"tools": [{"toolSpec": {"name": "parallel_local_search_one",
|
||||
"description": "Local search tool #1 for concurrency testing.", "inputSchema":
|
||||
{"json": {"properties": {"query": {"description": "Search query", "title": "Query",
|
||||
"type": "string"}}, "required": ["query"], "type": "object", "additionalProperties":
|
||||
false}}}}, {"toolSpec": {"name": "parallel_local_search_two", "description":
|
||||
"Local search tool #2 for concurrency testing.", "inputSchema": {"json": {"properties":
|
||||
{"query": {"description": "Search query", "title": "Query", "type": "string"}},
|
||||
"required": ["query"], "type": "object", "additionalProperties": false}}}},
|
||||
{"toolSpec": {"name": "parallel_local_search_three", "description": "Local search
|
||||
tool #3 for concurrency testing.", "inputSchema": {"json": {"properties": {"query":
|
||||
{"description": "Search query", "title": "Query", "type": "string"}}, "required":
|
||||
["query"], "type": "object", "additionalProperties": false}}}}]}}'
|
||||
headers:
|
||||
Content-Length:
|
||||
- '1954'
|
||||
Content-Type:
|
||||
- !!binary |
|
||||
YXBwbGljYXRpb24vanNvbg==
|
||||
User-Agent:
|
||||
- X-USER-AGENT-XXX
|
||||
amz-sdk-invocation-id:
|
||||
- AMZ-SDK-INVOCATION-ID-XXX
|
||||
amz-sdk-request:
|
||||
- !!binary |
|
||||
YXR0ZW1wdD0x
|
||||
authorization:
|
||||
- AUTHORIZATION-XXX
|
||||
x-amz-date:
|
||||
- X-AMZ-DATE-XXX
|
||||
method: POST
|
||||
uri: https://bedrock-runtime.us-east-1.amazonaws.com/model/anthropic.claude-3-haiku-20240307-v1%3A0/converse
|
||||
response:
|
||||
body:
|
||||
string: '{"message":"The security token included in the request is invalid."}'
|
||||
headers:
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '68'
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Thu, 19 Feb 2026 00:00:07 GMT
|
||||
x-amzn-ErrorType:
|
||||
- UnrecognizedClientException:http://internal.amazon.com/coral/com.amazon.coral.service/
|
||||
x-amzn-RequestId:
|
||||
- X-AMZN-REQUESTID-XXX
|
||||
status:
|
||||
code: 403
|
||||
message: Forbidden
|
||||
- request:
|
||||
body: '{"messages": [{"role": "user", "content": [{"text": "\nCurrent Task: This
|
||||
is a tool-calling compliance test. In your next assistant turn, emit exactly
|
||||
3 tool calls in the same response (parallel tool calls), in this order: 1) parallel_local_search_one(query=''latest
|
||||
OpenAI model release notes''), 2) parallel_local_search_two(query=''latest Anthropic
|
||||
model release notes''), 3) parallel_local_search_three(query=''latest Gemini
|
||||
model release notes''). Do not call any other tools and do not answer before
|
||||
those 3 tool calls are emitted. After the tool results return, provide a one
|
||||
paragraph summary.\n\nThis is the expected criteria for your final answer: A
|
||||
one sentence summary of both tool outputs\nyou MUST return the actual complete
|
||||
content as the final answer, not a summary."}]}, {"role": "user", "content":
|
||||
[{"text": "\nCurrent Task: This is a tool-calling compliance test. In your next
|
||||
assistant turn, emit exactly 3 tool calls in the same response (parallel tool
|
||||
calls), in this order: 1) parallel_local_search_one(query=''latest OpenAI model
|
||||
release notes''), 2) parallel_local_search_two(query=''latest Anthropic model
|
||||
release notes''), 3) parallel_local_search_three(query=''latest Gemini model
|
||||
release notes''). Do not call any other tools and do not answer before those
|
||||
3 tool calls are emitted. After the tool results return, provide a one paragraph
|
||||
summary.\n\nThis is the expected criteria for your final answer: A one sentence
|
||||
summary of both tool outputs\nyou MUST return the actual complete content as
|
||||
the final answer, not a summary."}]}], "inferenceConfig": {"stopSequences":
|
||||
["\nObservation:"]}, "system": [{"text": "You are Parallel Tool Agent. You follow
|
||||
tool instructions precisely.\nYour personal goal is: Use both tools exactly
|
||||
as instructed\n\nYou are Parallel Tool Agent. You follow tool instructions precisely.\nYour
|
||||
personal goal is: Use both tools exactly as instructed"}], "toolConfig": {"tools":
|
||||
[{"toolSpec": {"name": "parallel_local_search_one", "description": "Local search
|
||||
tool #1 for concurrency testing.", "inputSchema": {"json": {"properties": {"query":
|
||||
{"description": "Search query", "title": "Query", "type": "string"}}, "required":
|
||||
["query"], "type": "object", "additionalProperties": false}}}}, {"toolSpec":
|
||||
{"name": "parallel_local_search_two", "description": "Local search tool #2 for
|
||||
concurrency testing.", "inputSchema": {"json": {"properties": {"query": {"description":
|
||||
"Search query", "title": "Query", "type": "string"}}, "required": ["query"],
|
||||
"type": "object", "additionalProperties": false}}}}, {"toolSpec": {"name": "parallel_local_search_three",
|
||||
"description": "Local search tool #3 for concurrency testing.", "inputSchema":
|
||||
{"json": {"properties": {"query": {"description": "Search query", "title": "Query",
|
||||
"type": "string"}}, "required": ["query"], "type": "object", "additionalProperties":
|
||||
false}}}}]}}'
|
||||
headers:
|
||||
Content-Length:
|
||||
- '2855'
|
||||
Content-Type:
|
||||
- !!binary |
|
||||
YXBwbGljYXRpb24vanNvbg==
|
||||
User-Agent:
|
||||
- X-USER-AGENT-XXX
|
||||
amz-sdk-invocation-id:
|
||||
- AMZ-SDK-INVOCATION-ID-XXX
|
||||
amz-sdk-request:
|
||||
- !!binary |
|
||||
YXR0ZW1wdD0x
|
||||
authorization:
|
||||
- AUTHORIZATION-XXX
|
||||
x-amz-date:
|
||||
- X-AMZ-DATE-XXX
|
||||
method: POST
|
||||
uri: https://bedrock-runtime.us-east-1.amazonaws.com/model/anthropic.claude-3-haiku-20240307-v1%3A0/converse
|
||||
response:
|
||||
body:
|
||||
string: '{"message":"The security token included in the request is invalid."}'
|
||||
headers:
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '68'
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Thu, 19 Feb 2026 00:00:07 GMT
|
||||
x-amzn-ErrorType:
|
||||
- UnrecognizedClientException:http://internal.amazon.com/coral/com.amazon.coral.service/
|
||||
x-amzn-RequestId:
|
||||
- X-AMZN-REQUESTID-XXX
|
||||
status:
|
||||
code: 403
|
||||
message: Forbidden
|
||||
- request:
|
||||
body: '{"messages": [{"role": "user", "content": [{"text": "\nCurrent Task: This
|
||||
is a tool-calling compliance test. In your next assistant turn, emit exactly
|
||||
3 tool calls in the same response (parallel tool calls), in this order: 1) parallel_local_search_one(query=''latest
|
||||
OpenAI model release notes''), 2) parallel_local_search_two(query=''latest Anthropic
|
||||
model release notes''), 3) parallel_local_search_three(query=''latest Gemini
|
||||
model release notes''). Do not call any other tools and do not answer before
|
||||
those 3 tool calls are emitted. After the tool results return, provide a one
|
||||
paragraph summary.\n\nThis is the expected criteria for your final answer: A
|
||||
one sentence summary of both tool outputs\nyou MUST return the actual complete
|
||||
content as the final answer, not a summary."}]}, {"role": "user", "content":
|
||||
[{"text": "\nCurrent Task: This is a tool-calling compliance test. In your next
|
||||
assistant turn, emit exactly 3 tool calls in the same response (parallel tool
|
||||
calls), in this order: 1) parallel_local_search_one(query=''latest OpenAI model
|
||||
release notes''), 2) parallel_local_search_two(query=''latest Anthropic model
|
||||
release notes''), 3) parallel_local_search_three(query=''latest Gemini model
|
||||
release notes''). Do not call any other tools and do not answer before those
|
||||
3 tool calls are emitted. After the tool results return, provide a one paragraph
|
||||
summary.\n\nThis is the expected criteria for your final answer: A one sentence
|
||||
summary of both tool outputs\nyou MUST return the actual complete content as
|
||||
the final answer, not a summary."}]}, {"role": "user", "content": [{"text":
|
||||
"\nCurrent Task: This is a tool-calling compliance test. In your next assistant
|
||||
turn, emit exactly 3 tool calls in the same response (parallel tool calls),
|
||||
in this order: 1) parallel_local_search_one(query=''latest OpenAI model release
|
||||
notes''), 2) parallel_local_search_two(query=''latest Anthropic model release
|
||||
notes''), 3) parallel_local_search_three(query=''latest Gemini model release
|
||||
notes''). Do not call any other tools and do not answer before those 3 tool
|
||||
calls are emitted. After the tool results return, provide a one paragraph summary.\n\nThis
|
||||
is the expected criteria for your final answer: A one sentence summary of both
|
||||
tool outputs\nyou MUST return the actual complete content as the final answer,
|
||||
not a summary."}]}], "inferenceConfig": {"stopSequences": ["\nObservation:"]},
|
||||
"system": [{"text": "You are Parallel Tool Agent. You follow tool instructions
|
||||
precisely.\nYour personal goal is: Use both tools exactly as instructed\n\nYou
|
||||
are Parallel Tool Agent. You follow tool instructions precisely.\nYour personal
|
||||
goal is: Use both tools exactly as instructed\n\nYou are Parallel Tool Agent.
|
||||
You follow tool instructions precisely.\nYour personal goal is: Use both tools
|
||||
exactly as instructed"}], "toolConfig": {"tools": [{"toolSpec": {"name": "parallel_local_search_one",
|
||||
"description": "Local search tool #1 for concurrency testing.", "inputSchema":
|
||||
{"json": {"properties": {"query": {"description": "Search query", "title": "Query",
|
||||
"type": "string"}}, "required": ["query"], "type": "object", "additionalProperties":
|
||||
false}}}}, {"toolSpec": {"name": "parallel_local_search_two", "description":
|
||||
"Local search tool #2 for concurrency testing.", "inputSchema": {"json": {"properties":
|
||||
{"query": {"description": "Search query", "title": "Query", "type": "string"}},
|
||||
"required": ["query"], "type": "object", "additionalProperties": false}}}},
|
||||
{"toolSpec": {"name": "parallel_local_search_three", "description": "Local search
|
||||
tool #3 for concurrency testing.", "inputSchema": {"json": {"properties": {"query":
|
||||
{"description": "Search query", "title": "Query", "type": "string"}}, "required":
|
||||
["query"], "type": "object", "additionalProperties": false}}}}]}}'
|
||||
headers:
|
||||
Content-Length:
|
||||
- '3756'
|
||||
Content-Type:
|
||||
- !!binary |
|
||||
YXBwbGljYXRpb24vanNvbg==
|
||||
User-Agent:
|
||||
- X-USER-AGENT-XXX
|
||||
amz-sdk-invocation-id:
|
||||
- AMZ-SDK-INVOCATION-ID-XXX
|
||||
amz-sdk-request:
|
||||
- !!binary |
|
||||
YXR0ZW1wdD0x
|
||||
authorization:
|
||||
- AUTHORIZATION-XXX
|
||||
x-amz-date:
|
||||
- X-AMZ-DATE-XXX
|
||||
method: POST
|
||||
uri: https://bedrock-runtime.us-east-1.amazonaws.com/model/anthropic.claude-3-haiku-20240307-v1%3A0/converse
|
||||
response:
|
||||
body:
|
||||
string: '{"message":"The security token included in the request is invalid."}'
|
||||
headers:
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '68'
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Thu, 19 Feb 2026 00:00:07 GMT
|
||||
x-amzn-ErrorType:
|
||||
- UnrecognizedClientException:http://internal.amazon.com/coral/com.amazon.coral.service/
|
||||
x-amzn-RequestId:
|
||||
- X-AMZN-REQUESTID-XXX
|
||||
status:
|
||||
code: 403
|
||||
message: Forbidden
|
||||
version: 1
|
||||
@@ -3,14 +3,14 @@ interactions:
|
||||
body: '{"contents": [{"parts": [{"text": "\nCurrent Task: Calculate what is 15
|
||||
* 8\n\nThis is the expected criteria for your final answer: The result of the
|
||||
calculation\nyou MUST return the actual complete content as the final answer,
|
||||
not a summary.\n\nThis is VERY important to you, your job depends on it!"}],
|
||||
"role": "user"}], "systemInstruction": {"parts": [{"text": "You are Math Assistant.
|
||||
You are a helpful math assistant.\nYour personal goal is: Help users with mathematical
|
||||
calculations"}], "role": "user"}, "tools": [{"functionDeclarations": [{"description":
|
||||
"Perform mathematical calculations. Use this for any math operations.", "name":
|
||||
"calculator", "parameters": {"properties": {"expression": {"description": "Mathematical
|
||||
expression to evaluate", "title": "Expression", "type": "STRING"}}, "required":
|
||||
["expression"], "type": "OBJECT"}}]}], "generationConfig": {"stopSequences":
|
||||
not a summary."}], "role": "user"}], "systemInstruction": {"parts": [{"text":
|
||||
"You are Math Assistant. You are a helpful math assistant.\nYour personal goal
|
||||
is: Help users with mathematical calculations"}], "role": "user"}, "tools":
|
||||
[{"functionDeclarations": [{"description": "Perform mathematical calculations.
|
||||
Use this for any math operations.", "name": "calculator", "parameters_json_schema":
|
||||
{"properties": {"expression": {"description": "Mathematical expression to evaluate",
|
||||
"title": "Expression", "type": "string"}}, "required": ["expression"], "type":
|
||||
"object", "additionalProperties": false}}]}], "generationConfig": {"stopSequences":
|
||||
["\nObservation:"]}}'
|
||||
headers:
|
||||
User-Agent:
|
||||
@@ -22,7 +22,7 @@ interactions:
|
||||
connection:
|
||||
- keep-alive
|
||||
content-length:
|
||||
- '907'
|
||||
- '892'
|
||||
content-type:
|
||||
- application/json
|
||||
host:
|
||||
@@ -32,31 +32,31 @@ interactions:
|
||||
x-goog-api-key:
|
||||
- X-GOOG-API-KEY-XXX
|
||||
method: POST
|
||||
uri: https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-exp:generateContent
|
||||
uri: https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent
|
||||
response:
|
||||
body:
|
||||
string: "{\n \"candidates\": [\n {\n \"content\": {\n \"parts\":
|
||||
[\n {\n \"functionCall\": {\n \"name\": \"calculator\",\n
|
||||
\ \"args\": {\n \"expression\": \"15 * 8\"\n }\n
|
||||
\ }\n }\n ],\n \"role\": \"model\"\n },\n
|
||||
\ \"finishReason\": \"STOP\",\n \"avgLogprobs\": -0.00062879999833447594\n
|
||||
\ }\n ],\n \"usageMetadata\": {\n \"promptTokenCount\": 103,\n \"candidatesTokenCount\":
|
||||
7,\n \"totalTokenCount\": 110,\n \"promptTokensDetails\": [\n {\n
|
||||
\ \"modality\": \"TEXT\",\n \"tokenCount\": 103\n }\n ],\n
|
||||
\ \"candidatesTokensDetails\": [\n {\n \"modality\": \"TEXT\",\n
|
||||
\ \"tokenCount\": 7\n }\n ]\n },\n \"modelVersion\": \"gemini-2.0-flash-exp\",\n
|
||||
\ \"responseId\": \"PpByabfUHsih_uMPlu2ysAM\"\n}\n"
|
||||
\ },\n \"thoughtSignature\": \"Cp8DAb4+9vu74rJ0QQNTa6oMMh3QAlvx3cS4TL0I1od7EdQZtMBbsr5viQiTUR/LKj8nwPvtLjZxib5SXqmV0t2B2ZMdq1nqD62vLPD3i7tmUeRoysODfxomRGRhy/CPysMhobt5HWF1W/n6tNiQz3V36f0/dRx5yJeyN4tJL/RZePv77FUqywOfFlYOkOIyAkrE5LT6FicOjhHm/B9bGV/y7TNmN6TtwQDxoE9nU92Q/UNZ7rNyZE7aSR7KPJZuRXrrBBh+akt5dX5n6N9kGWkyRpWVgUox01+b22RSj4S/QY45IvadtmmkFk8DMVAtAnEiK0WazltC+TOdUJHwVgBD494fngoVcHU+R1yIJrVe7h6Ce3Ts5IYLrRCedDU3wW1ghn/hXx1nvTqQumpsGTGtE2v3KjF/7DmQA96WzB1X7+QUOF2J3pK9HemiKxAQl4U9fP2eNN8shvy2YykBlahWDujEwye7ji4wIWtNHbf0t+uFwGTQ3QruAKXvWB04ExjHM2I/8O9U5tOsH0cwPqnpFR2EaTqaPXXUllZ2K+DaaA==\"\n
|
||||
\ }\n ],\n \"role\": \"model\"\n },\n \"finishReason\":
|
||||
\"STOP\",\n \"index\": 0,\n \"finishMessage\": \"Model generated
|
||||
function call(s).\"\n }\n ],\n \"usageMetadata\": {\n \"promptTokenCount\":
|
||||
115,\n \"candidatesTokenCount\": 17,\n \"totalTokenCount\": 227,\n \"promptTokensDetails\":
|
||||
[\n {\n \"modality\": \"TEXT\",\n \"tokenCount\": 115\n
|
||||
\ }\n ],\n \"thoughtsTokenCount\": 95\n },\n \"modelVersion\":
|
||||
\"gemini-2.5-flash\",\n \"responseId\": \"Y1KWadvNMKz1jMcPiJeJmAI\"\n}\n"
|
||||
headers:
|
||||
Alt-Svc:
|
||||
- h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
|
||||
Content-Type:
|
||||
- application/json; charset=UTF-8
|
||||
Date:
|
||||
- Thu, 22 Jan 2026 21:01:50 GMT
|
||||
- Wed, 18 Feb 2026 23:59:32 GMT
|
||||
Server:
|
||||
- scaffolding on HTTPServer2
|
||||
Server-Timing:
|
||||
- gfet4t7; dur=521
|
||||
- gfet4t7; dur=956
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
Vary:
|
||||
@@ -76,18 +76,19 @@ interactions:
|
||||
body: '{"contents": [{"parts": [{"text": "\nCurrent Task: Calculate what is 15
|
||||
* 8\n\nThis is the expected criteria for your final answer: The result of the
|
||||
calculation\nyou MUST return the actual complete content as the final answer,
|
||||
not a summary.\n\nThis is VERY important to you, your job depends on it!"}],
|
||||
"role": "user"}, {"parts": [{"text": ""}], "role": "model"}, {"parts": [{"text":
|
||||
"The result of 15 * 8 is 120"}], "role": "user"}, {"parts": [{"text": "Analyze
|
||||
the tool result. If requirements are met, provide the Final Answer. Otherwise,
|
||||
call the next tool. Deliver only the answer without meta-commentary."}], "role":
|
||||
"user"}], "systemInstruction": {"parts": [{"text": "You are Math Assistant.
|
||||
You are a helpful math assistant.\nYour personal goal is: Help users with mathematical
|
||||
calculations"}], "role": "user"}, "tools": [{"functionDeclarations": [{"description":
|
||||
"Perform mathematical calculations. Use this for any math operations.", "name":
|
||||
"calculator", "parameters": {"properties": {"expression": {"description": "Mathematical
|
||||
expression to evaluate", "title": "Expression", "type": "STRING"}}, "required":
|
||||
["expression"], "type": "OBJECT"}}]}], "generationConfig": {"stopSequences":
|
||||
not a summary."}], "role": "user"}, {"parts": [{"functionCall": {"args": {"expression":
|
||||
"15 * 8"}, "name": "calculator"}}], "role": "model"}, {"parts": [{"functionResponse":
|
||||
{"name": "calculator", "response": {"result": "The result of 15 * 8 is 120"}}}],
|
||||
"role": "user"}, {"parts": [{"text": "Analyze the tool result. If requirements
|
||||
are met, provide the Final Answer. Otherwise, call the next tool. Deliver only
|
||||
the answer without meta-commentary."}], "role": "user"}], "systemInstruction":
|
||||
{"parts": [{"text": "You are Math Assistant. You are a helpful math assistant.\nYour
|
||||
personal goal is: Help users with mathematical calculations"}], "role": "user"},
|
||||
"tools": [{"functionDeclarations": [{"description": "Perform mathematical calculations.
|
||||
Use this for any math operations.", "name": "calculator", "parameters_json_schema":
|
||||
{"properties": {"expression": {"description": "Mathematical expression to evaluate",
|
||||
"title": "Expression", "type": "string"}}, "required": ["expression"], "type":
|
||||
"object", "additionalProperties": false}}]}], "generationConfig": {"stopSequences":
|
||||
["\nObservation:"]}}'
|
||||
headers:
|
||||
User-Agent:
|
||||
@@ -99,7 +100,7 @@ interactions:
|
||||
connection:
|
||||
- keep-alive
|
||||
content-length:
|
||||
- '1219'
|
||||
- '1326'
|
||||
content-type:
|
||||
- application/json
|
||||
host:
|
||||
@@ -109,378 +110,28 @@ interactions:
|
||||
x-goog-api-key:
|
||||
- X-GOOG-API-KEY-XXX
|
||||
method: POST
|
||||
uri: https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-exp:generateContent
|
||||
uri: https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent
|
||||
response:
|
||||
body:
|
||||
string: "{\n \"candidates\": [\n {\n \"content\": {\n \"parts\":
|
||||
[\n {\n \"functionCall\": {\n \"name\": \"calculator\",\n
|
||||
\ \"args\": {\n \"expression\": \"15 * 8\"\n }\n
|
||||
\ }\n }\n ],\n \"role\": \"model\"\n },\n
|
||||
\ \"finishReason\": \"STOP\",\n \"avgLogprobs\": -0.013549212898526872\n
|
||||
\ }\n ],\n \"usageMetadata\": {\n \"promptTokenCount\": 149,\n \"candidatesTokenCount\":
|
||||
7,\n \"totalTokenCount\": 156,\n \"promptTokensDetails\": [\n {\n
|
||||
\ \"modality\": \"TEXT\",\n \"tokenCount\": 149\n }\n ],\n
|
||||
\ \"candidatesTokensDetails\": [\n {\n \"modality\": \"TEXT\",\n
|
||||
\ \"tokenCount\": 7\n }\n ]\n },\n \"modelVersion\": \"gemini-2.0-flash-exp\",\n
|
||||
\ \"responseId\": \"P5Byadc8kJT-4w_p99XQAQ\"\n}\n"
|
||||
[\n {\n \"text\": \"The result of 15 * 8 is 120\"\n }\n
|
||||
\ ],\n \"role\": \"model\"\n },\n \"finishReason\":
|
||||
\"STOP\",\n \"index\": 0\n }\n ],\n \"usageMetadata\": {\n \"promptTokenCount\":
|
||||
191,\n \"candidatesTokenCount\": 14,\n \"totalTokenCount\": 205,\n \"promptTokensDetails\":
|
||||
[\n {\n \"modality\": \"TEXT\",\n \"tokenCount\": 191\n
|
||||
\ }\n ]\n },\n \"modelVersion\": \"gemini-2.5-flash\",\n \"responseId\":
|
||||
\"ZFKWaf2BMM6MjMcP6P--kQM\"\n}\n"
|
||||
headers:
|
||||
Alt-Svc:
|
||||
- h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
|
||||
Content-Type:
|
||||
- application/json; charset=UTF-8
|
||||
Date:
|
||||
- Thu, 22 Jan 2026 21:01:51 GMT
|
||||
- Wed, 18 Feb 2026 23:59:33 GMT
|
||||
Server:
|
||||
- scaffolding on HTTPServer2
|
||||
Server-Timing:
|
||||
- gfet4t7; dur=444
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
Vary:
|
||||
- Origin
|
||||
- X-Origin
|
||||
- Referer
|
||||
X-Content-Type-Options:
|
||||
- X-CONTENT-TYPE-XXX
|
||||
X-Frame-Options:
|
||||
- X-FRAME-OPTIONS-XXX
|
||||
X-XSS-Protection:
|
||||
- '0'
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: '{"contents": [{"parts": [{"text": "\nCurrent Task: Calculate what is 15
|
||||
* 8\n\nThis is the expected criteria for your final answer: The result of the
|
||||
calculation\nyou MUST return the actual complete content as the final answer,
|
||||
not a summary.\n\nThis is VERY important to you, your job depends on it!"}],
|
||||
"role": "user"}, {"parts": [{"text": ""}], "role": "model"}, {"parts": [{"text":
|
||||
"The result of 15 * 8 is 120"}], "role": "user"}, {"parts": [{"text": "Analyze
|
||||
the tool result. If requirements are met, provide the Final Answer. Otherwise,
|
||||
call the next tool. Deliver only the answer without meta-commentary."}], "role":
|
||||
"user"}, {"parts": [{"text": ""}], "role": "model"}, {"parts": [{"text": "The
|
||||
result of 15 * 8 is 120"}], "role": "user"}, {"parts": [{"text": "Analyze the
|
||||
tool result. If requirements are met, provide the Final Answer. Otherwise, call
|
||||
the next tool. Deliver only the answer without meta-commentary."}], "role":
|
||||
"user"}], "systemInstruction": {"parts": [{"text": "You are Math Assistant.
|
||||
You are a helpful math assistant.\nYour personal goal is: Help users with mathematical
|
||||
calculations"}], "role": "user"}, "tools": [{"functionDeclarations": [{"description":
|
||||
"Perform mathematical calculations. Use this for any math operations.", "name":
|
||||
"calculator", "parameters": {"properties": {"expression": {"description": "Mathematical
|
||||
expression to evaluate", "title": "Expression", "type": "STRING"}}, "required":
|
||||
["expression"], "type": "OBJECT"}}]}], "generationConfig": {"stopSequences":
|
||||
["\nObservation:"]}}'
|
||||
headers:
|
||||
User-Agent:
|
||||
- X-USER-AGENT-XXX
|
||||
accept:
|
||||
- '*/*'
|
||||
accept-encoding:
|
||||
- ACCEPT-ENCODING-XXX
|
||||
connection:
|
||||
- keep-alive
|
||||
content-length:
|
||||
- '1531'
|
||||
content-type:
|
||||
- application/json
|
||||
host:
|
||||
- generativelanguage.googleapis.com
|
||||
x-goog-api-client:
|
||||
- google-genai-sdk/1.49.0 gl-python/3.13.3
|
||||
x-goog-api-key:
|
||||
- X-GOOG-API-KEY-XXX
|
||||
method: POST
|
||||
uri: https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-exp:generateContent
|
||||
response:
|
||||
body:
|
||||
string: "{\n \"candidates\": [\n {\n \"content\": {\n \"parts\":
|
||||
[\n {\n \"functionCall\": {\n \"name\": \"calculator\",\n
|
||||
\ \"args\": {\n \"expression\": \"15 * 8\"\n }\n
|
||||
\ }\n }\n ],\n \"role\": \"model\"\n },\n
|
||||
\ \"finishReason\": \"STOP\",\n \"avgLogprobs\": -0.0409286447933742\n
|
||||
\ }\n ],\n \"usageMetadata\": {\n \"promptTokenCount\": 195,\n \"candidatesTokenCount\":
|
||||
7,\n \"totalTokenCount\": 202,\n \"promptTokensDetails\": [\n {\n
|
||||
\ \"modality\": \"TEXT\",\n \"tokenCount\": 195\n }\n ],\n
|
||||
\ \"candidatesTokensDetails\": [\n {\n \"modality\": \"TEXT\",\n
|
||||
\ \"tokenCount\": 7\n }\n ]\n },\n \"modelVersion\": \"gemini-2.0-flash-exp\",\n
|
||||
\ \"responseId\": \"P5Byadn5HOK6_uMPnvmXwAk\"\n}\n"
|
||||
headers:
|
||||
Alt-Svc:
|
||||
- h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
|
||||
Content-Type:
|
||||
- application/json; charset=UTF-8
|
||||
Date:
|
||||
- Thu, 22 Jan 2026 21:01:51 GMT
|
||||
Server:
|
||||
- scaffolding on HTTPServer2
|
||||
Server-Timing:
|
||||
- gfet4t7; dur=503
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
Vary:
|
||||
- Origin
|
||||
- X-Origin
|
||||
- Referer
|
||||
X-Content-Type-Options:
|
||||
- X-CONTENT-TYPE-XXX
|
||||
X-Frame-Options:
|
||||
- X-FRAME-OPTIONS-XXX
|
||||
X-XSS-Protection:
|
||||
- '0'
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: '{"contents": [{"parts": [{"text": "\nCurrent Task: Calculate what is 15
|
||||
* 8\n\nThis is the expected criteria for your final answer: The result of the
|
||||
calculation\nyou MUST return the actual complete content as the final answer,
|
||||
not a summary.\n\nThis is VERY important to you, your job depends on it!"}],
|
||||
"role": "user"}, {"parts": [{"text": ""}], "role": "model"}, {"parts": [{"text":
|
||||
"The result of 15 * 8 is 120"}], "role": "user"}, {"parts": [{"text": "Analyze
|
||||
the tool result. If requirements are met, provide the Final Answer. Otherwise,
|
||||
call the next tool. Deliver only the answer without meta-commentary."}], "role":
|
||||
"user"}, {"parts": [{"text": ""}], "role": "model"}, {"parts": [{"text": "The
|
||||
result of 15 * 8 is 120"}], "role": "user"}, {"parts": [{"text": "Analyze the
|
||||
tool result. If requirements are met, provide the Final Answer. Otherwise, call
|
||||
the next tool. Deliver only the answer without meta-commentary."}], "role":
|
||||
"user"}, {"parts": [{"text": ""}], "role": "model"}, {"parts": [{"text": "The
|
||||
result of 15 * 8 is 120"}], "role": "user"}, {"parts": [{"text": "Analyze the
|
||||
tool result. If requirements are met, provide the Final Answer. Otherwise, call
|
||||
the next tool. Deliver only the answer without meta-commentary."}], "role":
|
||||
"user"}], "systemInstruction": {"parts": [{"text": "You are Math Assistant.
|
||||
You are a helpful math assistant.\nYour personal goal is: Help users with mathematical
|
||||
calculations"}], "role": "user"}, "tools": [{"functionDeclarations": [{"description":
|
||||
"Perform mathematical calculations. Use this for any math operations.", "name":
|
||||
"calculator", "parameters": {"properties": {"expression": {"description": "Mathematical
|
||||
expression to evaluate", "title": "Expression", "type": "STRING"}}, "required":
|
||||
["expression"], "type": "OBJECT"}}]}], "generationConfig": {"stopSequences":
|
||||
["\nObservation:"]}}'
|
||||
headers:
|
||||
User-Agent:
|
||||
- X-USER-AGENT-XXX
|
||||
accept:
|
||||
- '*/*'
|
||||
accept-encoding:
|
||||
- ACCEPT-ENCODING-XXX
|
||||
connection:
|
||||
- keep-alive
|
||||
content-length:
|
||||
- '1843'
|
||||
content-type:
|
||||
- application/json
|
||||
host:
|
||||
- generativelanguage.googleapis.com
|
||||
x-goog-api-client:
|
||||
- google-genai-sdk/1.49.0 gl-python/3.13.3
|
||||
x-goog-api-key:
|
||||
- X-GOOG-API-KEY-XXX
|
||||
method: POST
|
||||
uri: https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-exp:generateContent
|
||||
response:
|
||||
body:
|
||||
string: "{\n \"candidates\": [\n {\n \"content\": {\n \"parts\":
|
||||
[\n {\n \"functionCall\": {\n \"name\": \"calculator\",\n
|
||||
\ \"args\": {\n \"expression\": \"15 * 8\"\n }\n
|
||||
\ }\n }\n ],\n \"role\": \"model\"\n },\n
|
||||
\ \"finishReason\": \"STOP\",\n \"avgLogprobs\": -0.018002046006066457\n
|
||||
\ }\n ],\n \"usageMetadata\": {\n \"promptTokenCount\": 241,\n \"candidatesTokenCount\":
|
||||
7,\n \"totalTokenCount\": 248,\n \"promptTokensDetails\": [\n {\n
|
||||
\ \"modality\": \"TEXT\",\n \"tokenCount\": 241\n }\n ],\n
|
||||
\ \"candidatesTokensDetails\": [\n {\n \"modality\": \"TEXT\",\n
|
||||
\ \"tokenCount\": 7\n }\n ]\n },\n \"modelVersion\": \"gemini-2.0-flash-exp\",\n
|
||||
\ \"responseId\": \"P5Byafi2PKbn_uMPtIbfuQI\"\n}\n"
|
||||
headers:
|
||||
Alt-Svc:
|
||||
- h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
|
||||
Content-Type:
|
||||
- application/json; charset=UTF-8
|
||||
Date:
|
||||
- Thu, 22 Jan 2026 21:01:52 GMT
|
||||
Server:
|
||||
- scaffolding on HTTPServer2
|
||||
Server-Timing:
|
||||
- gfet4t7; dur=482
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
Vary:
|
||||
- Origin
|
||||
- X-Origin
|
||||
- Referer
|
||||
X-Content-Type-Options:
|
||||
- X-CONTENT-TYPE-XXX
|
||||
X-Frame-Options:
|
||||
- X-FRAME-OPTIONS-XXX
|
||||
X-XSS-Protection:
|
||||
- '0'
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: '{"contents": [{"parts": [{"text": "\nCurrent Task: Calculate what is 15
|
||||
* 8\n\nThis is the expected criteria for your final answer: The result of the
|
||||
calculation\nyou MUST return the actual complete content as the final answer,
|
||||
not a summary.\n\nThis is VERY important to you, your job depends on it!"}],
|
||||
"role": "user"}, {"parts": [{"text": ""}], "role": "model"}, {"parts": [{"text":
|
||||
"The result of 15 * 8 is 120"}], "role": "user"}, {"parts": [{"text": "Analyze
|
||||
the tool result. If requirements are met, provide the Final Answer. Otherwise,
|
||||
call the next tool. Deliver only the answer without meta-commentary."}], "role":
|
||||
"user"}, {"parts": [{"text": ""}], "role": "model"}, {"parts": [{"text": "The
|
||||
result of 15 * 8 is 120"}], "role": "user"}, {"parts": [{"text": "Analyze the
|
||||
tool result. If requirements are met, provide the Final Answer. Otherwise, call
|
||||
the next tool. Deliver only the answer without meta-commentary."}], "role":
|
||||
"user"}, {"parts": [{"text": ""}], "role": "model"}, {"parts": [{"text": "The
|
||||
result of 15 * 8 is 120"}], "role": "user"}, {"parts": [{"text": "Analyze the
|
||||
tool result. If requirements are met, provide the Final Answer. Otherwise, call
|
||||
the next tool. Deliver only the answer without meta-commentary."}], "role":
|
||||
"user"}, {"parts": [{"text": ""}], "role": "model"}, {"parts": [{"text": "The
|
||||
result of 15 * 8 is 120"}], "role": "user"}, {"parts": [{"text": "Analyze the
|
||||
tool result. If requirements are met, provide the Final Answer. Otherwise, call
|
||||
the next tool. Deliver only the answer without meta-commentary."}], "role":
|
||||
"user"}], "systemInstruction": {"parts": [{"text": "You are Math Assistant.
|
||||
You are a helpful math assistant.\nYour personal goal is: Help users with mathematical
|
||||
calculations"}], "role": "user"}, "tools": [{"functionDeclarations": [{"description":
|
||||
"Perform mathematical calculations. Use this for any math operations.", "name":
|
||||
"calculator", "parameters": {"properties": {"expression": {"description": "Mathematical
|
||||
expression to evaluate", "title": "Expression", "type": "STRING"}}, "required":
|
||||
["expression"], "type": "OBJECT"}}]}], "generationConfig": {"stopSequences":
|
||||
["\nObservation:"]}}'
|
||||
headers:
|
||||
User-Agent:
|
||||
- X-USER-AGENT-XXX
|
||||
accept:
|
||||
- '*/*'
|
||||
accept-encoding:
|
||||
- ACCEPT-ENCODING-XXX
|
||||
connection:
|
||||
- keep-alive
|
||||
content-length:
|
||||
- '2155'
|
||||
content-type:
|
||||
- application/json
|
||||
host:
|
||||
- generativelanguage.googleapis.com
|
||||
x-goog-api-client:
|
||||
- google-genai-sdk/1.49.0 gl-python/3.13.3
|
||||
x-goog-api-key:
|
||||
- X-GOOG-API-KEY-XXX
|
||||
method: POST
|
||||
uri: https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-exp:generateContent
|
||||
response:
|
||||
body:
|
||||
string: "{\n \"candidates\": [\n {\n \"content\": {\n \"parts\":
|
||||
[\n {\n \"functionCall\": {\n \"name\": \"calculator\",\n
|
||||
\ \"args\": {\n \"expression\": \"15 * 8\"\n }\n
|
||||
\ }\n }\n ],\n \"role\": \"model\"\n },\n
|
||||
\ \"finishReason\": \"STOP\",\n \"avgLogprobs\": -0.10329001290457589\n
|
||||
\ }\n ],\n \"usageMetadata\": {\n \"promptTokenCount\": 287,\n \"candidatesTokenCount\":
|
||||
7,\n \"totalTokenCount\": 294,\n \"promptTokensDetails\": [\n {\n
|
||||
\ \"modality\": \"TEXT\",\n \"tokenCount\": 287\n }\n ],\n
|
||||
\ \"candidatesTokensDetails\": [\n {\n \"modality\": \"TEXT\",\n
|
||||
\ \"tokenCount\": 7\n }\n ]\n },\n \"modelVersion\": \"gemini-2.0-flash-exp\",\n
|
||||
\ \"responseId\": \"QJByaamVIP_g_uMPt6mI0Qg\"\n}\n"
|
||||
headers:
|
||||
Alt-Svc:
|
||||
- h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
|
||||
Content-Type:
|
||||
- application/json; charset=UTF-8
|
||||
Date:
|
||||
- Thu, 22 Jan 2026 21:01:52 GMT
|
||||
Server:
|
||||
- scaffolding on HTTPServer2
|
||||
Server-Timing:
|
||||
- gfet4t7; dur=534
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
Vary:
|
||||
- Origin
|
||||
- X-Origin
|
||||
- Referer
|
||||
X-Content-Type-Options:
|
||||
- X-CONTENT-TYPE-XXX
|
||||
X-Frame-Options:
|
||||
- X-FRAME-OPTIONS-XXX
|
||||
X-XSS-Protection:
|
||||
- '0'
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: '{"contents": [{"parts": [{"text": "\nCurrent Task: Calculate what is 15
|
||||
* 8\n\nThis is the expected criteria for your final answer: The result of the
|
||||
calculation\nyou MUST return the actual complete content as the final answer,
|
||||
not a summary.\n\nThis is VERY important to you, your job depends on it!"}],
|
||||
"role": "user"}, {"parts": [{"text": ""}], "role": "model"}, {"parts": [{"text":
|
||||
"The result of 15 * 8 is 120"}], "role": "user"}, {"parts": [{"text": "Analyze
|
||||
the tool result. If requirements are met, provide the Final Answer. Otherwise,
|
||||
call the next tool. Deliver only the answer without meta-commentary."}], "role":
|
||||
"user"}, {"parts": [{"text": ""}], "role": "model"}, {"parts": [{"text": "The
|
||||
result of 15 * 8 is 120"}], "role": "user"}, {"parts": [{"text": "Analyze the
|
||||
tool result. If requirements are met, provide the Final Answer. Otherwise, call
|
||||
the next tool. Deliver only the answer without meta-commentary."}], "role":
|
||||
"user"}, {"parts": [{"text": ""}], "role": "model"}, {"parts": [{"text": "The
|
||||
result of 15 * 8 is 120"}], "role": "user"}, {"parts": [{"text": "Analyze the
|
||||
tool result. If requirements are met, provide the Final Answer. Otherwise, call
|
||||
the next tool. Deliver only the answer without meta-commentary."}], "role":
|
||||
"user"}, {"parts": [{"text": ""}], "role": "model"}, {"parts": [{"text": "The
|
||||
result of 15 * 8 is 120"}], "role": "user"}, {"parts": [{"text": "Analyze the
|
||||
tool result. If requirements are met, provide the Final Answer. Otherwise, call
|
||||
the next tool. Deliver only the answer without meta-commentary."}], "role":
|
||||
"user"}, {"parts": [{"text": ""}], "role": "model"}, {"parts": [{"text": "The
|
||||
result of 15 * 8 is 120"}], "role": "user"}, {"parts": [{"text": "Analyze the
|
||||
tool result. If requirements are met, provide the Final Answer. Otherwise, call
|
||||
the next tool. Deliver only the answer without meta-commentary."}], "role":
|
||||
"user"}], "systemInstruction": {"parts": [{"text": "You are Math Assistant.
|
||||
You are a helpful math assistant.\nYour personal goal is: Help users with mathematical
|
||||
calculations"}], "role": "user"}, "tools": [{"functionDeclarations": [{"description":
|
||||
"Perform mathematical calculations. Use this for any math operations.", "name":
|
||||
"calculator", "parameters": {"properties": {"expression": {"description": "Mathematical
|
||||
expression to evaluate", "title": "Expression", "type": "STRING"}}, "required":
|
||||
["expression"], "type": "OBJECT"}}]}], "generationConfig": {"stopSequences":
|
||||
["\nObservation:"]}}'
|
||||
headers:
|
||||
User-Agent:
|
||||
- X-USER-AGENT-XXX
|
||||
accept:
|
||||
- '*/*'
|
||||
accept-encoding:
|
||||
- ACCEPT-ENCODING-XXX
|
||||
connection:
|
||||
- keep-alive
|
||||
content-length:
|
||||
- '2467'
|
||||
content-type:
|
||||
- application/json
|
||||
host:
|
||||
- generativelanguage.googleapis.com
|
||||
x-goog-api-client:
|
||||
- google-genai-sdk/1.49.0 gl-python/3.13.3
|
||||
x-goog-api-key:
|
||||
- X-GOOG-API-KEY-XXX
|
||||
method: POST
|
||||
uri: https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-exp:generateContent
|
||||
response:
|
||||
body:
|
||||
string: "{\n \"candidates\": [\n {\n \"content\": {\n \"parts\":
|
||||
[\n {\n \"text\": \"120\\n\"\n }\n ],\n
|
||||
\ \"role\": \"model\"\n },\n \"finishReason\": \"STOP\",\n
|
||||
\ \"avgLogprobs\": -0.0097615998238325119\n }\n ],\n \"usageMetadata\":
|
||||
{\n \"promptTokenCount\": 333,\n \"candidatesTokenCount\": 4,\n \"totalTokenCount\":
|
||||
337,\n \"promptTokensDetails\": [\n {\n \"modality\": \"TEXT\",\n
|
||||
\ \"tokenCount\": 333\n }\n ],\n \"candidatesTokensDetails\":
|
||||
[\n {\n \"modality\": \"TEXT\",\n \"tokenCount\": 4\n }\n
|
||||
\ ]\n },\n \"modelVersion\": \"gemini-2.0-flash-exp\",\n \"responseId\":
|
||||
\"QZByaZHABO-i_uMP58aYqAk\"\n}\n"
|
||||
headers:
|
||||
Alt-Svc:
|
||||
- h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
|
||||
Content-Type:
|
||||
- application/json; charset=UTF-8
|
||||
Date:
|
||||
- Thu, 22 Jan 2026 21:01:53 GMT
|
||||
Server:
|
||||
- scaffolding on HTTPServer2
|
||||
Server-Timing:
|
||||
- gfet4t7; dur=412
|
||||
- gfet4t7; dur=421
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
Vary:
|
||||
|
||||
@@ -0,0 +1,188 @@
|
||||
interactions:
|
||||
- request:
|
||||
body: '{"contents": [{"parts": [{"text": "\nCurrent Task: This is a tool-calling
|
||||
compliance test. In your next assistant turn, emit exactly 3 tool calls in the
|
||||
same response (parallel tool calls), in this order: 1) parallel_local_search_one(query=''latest
|
||||
OpenAI model release notes''), 2) parallel_local_search_two(query=''latest Anthropic
|
||||
model release notes''), 3) parallel_local_search_three(query=''latest Gemini
|
||||
model release notes''). Do not call any other tools and do not answer before
|
||||
those 3 tool calls are emitted. After the tool results return, provide a one
|
||||
paragraph summary."}], "role": "user"}], "systemInstruction": {"parts": [{"text":
|
||||
"You are Parallel Tool Agent. You follow tool instructions precisely.\nYour
|
||||
personal goal is: Use both tools exactly as instructed"}], "role": "user"},
|
||||
"tools": [{"functionDeclarations": [{"description": "Local search tool #1 for
|
||||
concurrency testing.", "name": "parallel_local_search_one", "parameters_json_schema":
|
||||
{"properties": {"query": {"description": "Search query", "title": "Query", "type":
|
||||
"string"}}, "required": ["query"], "type": "object", "additionalProperties":
|
||||
false}}, {"description": "Local search tool #2 for concurrency testing.", "name":
|
||||
"parallel_local_search_two", "parameters_json_schema": {"properties": {"query":
|
||||
{"description": "Search query", "title": "Query", "type": "string"}}, "required":
|
||||
["query"], "type": "object", "additionalProperties": false}}, {"description":
|
||||
"Local search tool #3 for concurrency testing.", "name": "parallel_local_search_three",
|
||||
"parameters_json_schema": {"properties": {"query": {"description": "Search query",
|
||||
"title": "Query", "type": "string"}}, "required": ["query"], "type": "object",
|
||||
"additionalProperties": false}}]}], "generationConfig": {"stopSequences": ["\nObservation:"]}}'
|
||||
headers:
|
||||
User-Agent:
|
||||
- X-USER-AGENT-XXX
|
||||
accept:
|
||||
- '*/*'
|
||||
accept-encoding:
|
||||
- ACCEPT-ENCODING-XXX
|
||||
connection:
|
||||
- keep-alive
|
||||
content-length:
|
||||
- '1783'
|
||||
content-type:
|
||||
- application/json
|
||||
host:
|
||||
- generativelanguage.googleapis.com
|
||||
x-goog-api-client:
|
||||
- google-genai-sdk/1.49.0 gl-python/3.13.3
|
||||
x-goog-api-key:
|
||||
- X-GOOG-API-KEY-XXX
|
||||
method: POST
|
||||
uri: https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent
|
||||
response:
|
||||
body:
|
||||
string: "{\n \"candidates\": [\n {\n \"content\": {\n \"parts\":
|
||||
[\n {\n \"functionCall\": {\n \"name\": \"parallel_local_search_one\",\n
|
||||
\ \"args\": {\n \"query\": \"latest OpenAI model
|
||||
release notes\"\n }\n },\n \"thoughtSignature\":
|
||||
\"CrICAb4+9vtrrkiSatPyOs7fssb9akcgCIiQdJKp/k+hcEZVNFvU/H0e4FFmLIhTCPRyHxmU+AQPtBZ5vg6y9ZCcv11RdcWgYW8rPQzCnC+YTUxPAfDzaObky1QsL5pl9+yglQqVoVM31ZcnoiH02z85pwAv6TSJxdJZEekW6XwcIrCoHNCgY3ghHFEd3y3wLJ5JWL7wmiRNTC9TCT8aJHXKFohYrb+4JMULCx8BqKVxOucZPiDHA8GsoqSlzkYEe2xCh9oSdaZpCFrxhZ9bwoVDbVmPrjaq2hj5BoJ5hNxscHJ/E0EOl4ogeKZW+hIVfdzpjAFZW9Oejkb9G4ZSLbxXsoO7x8bi4LHFRABniGrWvNuOOH0Udh4t57oXHXZO4u5NNTood/GkJGcP+aHqUAH1fwqL\"\n
|
||||
\ },\n {\n \"functionCall\": {\n \"name\":
|
||||
\"parallel_local_search_two\",\n \"args\": {\n \"query\":
|
||||
\"latest Anthropic model release notes\"\n }\n }\n
|
||||
\ },\n {\n \"functionCall\": {\n \"name\":
|
||||
\"parallel_local_search_three\",\n \"args\": {\n \"query\":
|
||||
\"latest Gemini model release notes\"\n }\n }\n }\n
|
||||
\ ],\n \"role\": \"model\"\n },\n \"finishReason\":
|
||||
\"STOP\",\n \"index\": 0,\n \"finishMessage\": \"Model generated
|
||||
function call(s).\"\n }\n ],\n \"usageMetadata\": {\n \"promptTokenCount\":
|
||||
291,\n \"candidatesTokenCount\": 70,\n \"totalTokenCount\": 428,\n \"promptTokensDetails\":
|
||||
[\n {\n \"modality\": \"TEXT\",\n \"tokenCount\": 291\n
|
||||
\ }\n ],\n \"thoughtsTokenCount\": 67\n },\n \"modelVersion\":
|
||||
\"gemini-2.5-flash\",\n \"responseId\": \"alKWacytCLi5jMcPhISaoAI\"\n}\n"
|
||||
headers:
|
||||
Alt-Svc:
|
||||
- h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
|
||||
Content-Type:
|
||||
- application/json; charset=UTF-8
|
||||
Date:
|
||||
- Wed, 18 Feb 2026 23:59:39 GMT
|
||||
Server:
|
||||
- scaffolding on HTTPServer2
|
||||
Server-Timing:
|
||||
- gfet4t7; dur=999
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
Vary:
|
||||
- Origin
|
||||
- X-Origin
|
||||
- Referer
|
||||
X-Content-Type-Options:
|
||||
- X-CONTENT-TYPE-XXX
|
||||
X-Frame-Options:
|
||||
- X-FRAME-OPTIONS-XXX
|
||||
X-XSS-Protection:
|
||||
- '0'
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: '{"contents": [{"parts": [{"text": "\nCurrent Task: This is a tool-calling
|
||||
compliance test. In your next assistant turn, emit exactly 3 tool calls in the
|
||||
same response (parallel tool calls), in this order: 1) parallel_local_search_one(query=''latest
|
||||
OpenAI model release notes''), 2) parallel_local_search_two(query=''latest Anthropic
|
||||
model release notes''), 3) parallel_local_search_three(query=''latest Gemini
|
||||
model release notes''). Do not call any other tools and do not answer before
|
||||
those 3 tool calls are emitted. After the tool results return, provide a one
|
||||
paragraph summary."}], "role": "user"}, {"parts": [{"functionCall": {"args":
|
||||
{"query": "latest OpenAI model release notes"}, "name": "parallel_local_search_one"},
|
||||
"thoughtSignature": "CrICAb4-9vtrrkiSatPyOs7fssb9akcgCIiQdJKp_k-hcEZVNFvU_H0e4FFmLIhTCPRyHxmU-AQPtBZ5vg6y9ZCcv11RdcWgYW8rPQzCnC-YTUxPAfDzaObky1QsL5pl9-yglQqVoVM31ZcnoiH02z85pwAv6TSJxdJZEekW6XwcIrCoHNCgY3ghHFEd3y3wLJ5JWL7wmiRNTC9TCT8aJHXKFohYrb-4JMULCx8BqKVxOucZPiDHA8GsoqSlzkYEe2xCh9oSdaZpCFrxhZ9bwoVDbVmPrjaq2hj5BoJ5hNxscHJ_E0EOl4ogeKZW-hIVfdzpjAFZW9Oejkb9G4ZSLbxXsoO7x8bi4LHFRABniGrWvNuOOH0Udh4t57oXHXZO4u5NNTood_GkJGcP-aHqUAH1fwqL"},
|
||||
{"functionCall": {"args": {"query": "latest Anthropic model release notes"},
|
||||
"name": "parallel_local_search_two"}}, {"functionCall": {"args": {"query": "latest
|
||||
Gemini model release notes"}, "name": "parallel_local_search_three"}}], "role":
|
||||
"model"}, {"parts": [{"functionResponse": {"name": "parallel_local_search_one",
|
||||
"response": {"result": "[one] latest OpenAI model release notes"}}}], "role":
|
||||
"user"}, {"parts": [{"functionResponse": {"name": "parallel_local_search_two",
|
||||
"response": {"result": "[two] latest Anthropic model release notes"}}}], "role":
|
||||
"user"}, {"parts": [{"functionResponse": {"name": "parallel_local_search_three",
|
||||
"response": {"result": "[three] latest Gemini model release notes"}}}], "role":
|
||||
"user"}], "systemInstruction": {"parts": [{"text": "You are Parallel Tool Agent.
|
||||
You follow tool instructions precisely.\nYour personal goal is: Use both tools
|
||||
exactly as instructed"}], "role": "user"}, "tools": [{"functionDeclarations":
|
||||
[{"description": "Local search tool #1 for concurrency testing.", "name": "parallel_local_search_one",
|
||||
"parameters_json_schema": {"properties": {"query": {"description": "Search query",
|
||||
"title": "Query", "type": "string"}}, "required": ["query"], "type": "object",
|
||||
"additionalProperties": false}}, {"description": "Local search tool #2 for concurrency
|
||||
testing.", "name": "parallel_local_search_two", "parameters_json_schema": {"properties":
|
||||
{"query": {"description": "Search query", "title": "Query", "type": "string"}},
|
||||
"required": ["query"], "type": "object", "additionalProperties": false}}, {"description":
|
||||
"Local search tool #3 for concurrency testing.", "name": "parallel_local_search_three",
|
||||
"parameters_json_schema": {"properties": {"query": {"description": "Search query",
|
||||
"title": "Query", "type": "string"}}, "required": ["query"], "type": "object",
|
||||
"additionalProperties": false}}]}], "generationConfig": {"stopSequences": ["\nObservation:"]}}'
|
||||
headers:
|
||||
User-Agent:
|
||||
- X-USER-AGENT-XXX
|
||||
accept:
|
||||
- '*/*'
|
||||
accept-encoding:
|
||||
- ACCEPT-ENCODING-XXX
|
||||
connection:
|
||||
- keep-alive
|
||||
content-length:
|
||||
- '3071'
|
||||
content-type:
|
||||
- application/json
|
||||
host:
|
||||
- generativelanguage.googleapis.com
|
||||
x-goog-api-client:
|
||||
- google-genai-sdk/1.49.0 gl-python/3.13.3
|
||||
x-goog-api-key:
|
||||
- X-GOOG-API-KEY-XXX
|
||||
method: POST
|
||||
uri: https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent
|
||||
response:
|
||||
body:
|
||||
string: "{\n \"candidates\": [\n {\n \"content\": {\n \"parts\":
|
||||
[\n {\n \"text\": \"Here is a summary of the latest model
|
||||
release notes: I have retrieved information regarding the latest OpenAI model
|
||||
release notes, the latest Anthropic model release notes, and the latest Gemini
|
||||
model release notes. The specific details of these release notes are available
|
||||
through the respective tool outputs.\",\n \"thoughtSignature\":
|
||||
\"CsoBAb4+9vtPvWFM08lR1S4QrLN+Z1+Zpf04Y/bC8tjOpnxz3EEvHyRNEwkslUX5pftBi8J78Xk4/FUER0xjJZc8clUObTvayxLNup4h1JwJ5ZdatulInNGTEieFnF4w8KjSFB/vqNCZvXWZbiLkpzqAnsoAIf0x4VmMN11V0Ozo+3f2QftD+iBrfu3g21UI5tbG0Z+0QHxjRVKXrQOp7dmoZPzaxI0zalfDEI+A2jGpVl/VvauVNv0jQn0yItcA5tkVeWLq6717CjNoig==\"\n
|
||||
\ }\n ],\n \"role\": \"model\"\n },\n \"finishReason\":
|
||||
\"STOP\",\n \"index\": 0\n }\n ],\n \"usageMetadata\": {\n \"promptTokenCount\":
|
||||
435,\n \"candidatesTokenCount\": 54,\n \"totalTokenCount\": 524,\n \"promptTokensDetails\":
|
||||
[\n {\n \"modality\": \"TEXT\",\n \"tokenCount\": 435\n
|
||||
\ }\n ],\n \"thoughtsTokenCount\": 35\n },\n \"modelVersion\":
|
||||
\"gemini-2.5-flash\",\n \"responseId\": \"bFKWaZOZCqCvjMcPvvGNgAc\"\n}\n"
|
||||
headers:
|
||||
Alt-Svc:
|
||||
- h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
|
||||
Content-Type:
|
||||
- application/json; charset=UTF-8
|
||||
Date:
|
||||
- Wed, 18 Feb 2026 23:59:41 GMT
|
||||
Server:
|
||||
- scaffolding on HTTPServer2
|
||||
Server-Timing:
|
||||
- gfet4t7; dur=967
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
Vary:
|
||||
- Origin
|
||||
- X-Origin
|
||||
- Referer
|
||||
X-Content-Type-Options:
|
||||
- X-CONTENT-TYPE-XXX
|
||||
X-Frame-Options:
|
||||
- X-FRAME-OPTIONS-XXX
|
||||
X-XSS-Protection:
|
||||
- '0'
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
version: 1
|
||||
@@ -0,0 +1,192 @@
|
||||
interactions:
|
||||
- request:
|
||||
body: '{"contents": [{"parts": [{"text": "\nCurrent Task: This is a tool-calling
|
||||
compliance test. In your next assistant turn, emit exactly 3 tool calls in the
|
||||
same response (parallel tool calls), in this order: 1) parallel_local_search_one(query=''latest
|
||||
OpenAI model release notes''), 2) parallel_local_search_two(query=''latest Anthropic
|
||||
model release notes''), 3) parallel_local_search_three(query=''latest Gemini
|
||||
model release notes''). Do not call any other tools and do not answer before
|
||||
those 3 tool calls are emitted. After the tool results return, provide a one
|
||||
paragraph summary.\n\nThis is the expected criteria for your final answer: A
|
||||
one sentence summary of both tool outputs\nyou MUST return the actual complete
|
||||
content as the final answer, not a summary."}], "role": "user"}], "systemInstruction":
|
||||
{"parts": [{"text": "You are Parallel Tool Agent. You follow tool instructions
|
||||
precisely.\nYour personal goal is: Use both tools exactly as instructed"}],
|
||||
"role": "user"}, "tools": [{"functionDeclarations": [{"description": "Local
|
||||
search tool #1 for concurrency testing.", "name": "parallel_local_search_one",
|
||||
"parameters_json_schema": {"properties": {"query": {"description": "Search query",
|
||||
"title": "Query", "type": "string"}}, "required": ["query"], "type": "object",
|
||||
"additionalProperties": false}}, {"description": "Local search tool #2 for concurrency
|
||||
testing.", "name": "parallel_local_search_two", "parameters_json_schema": {"properties":
|
||||
{"query": {"description": "Search query", "title": "Query", "type": "string"}},
|
||||
"required": ["query"], "type": "object", "additionalProperties": false}}, {"description":
|
||||
"Local search tool #3 for concurrency testing.", "name": "parallel_local_search_three",
|
||||
"parameters_json_schema": {"properties": {"query": {"description": "Search query",
|
||||
"title": "Query", "type": "string"}}, "required": ["query"], "type": "object",
|
||||
"additionalProperties": false}}]}], "generationConfig": {"stopSequences": ["\nObservation:"]}}'
|
||||
headers:
|
||||
User-Agent:
|
||||
- X-USER-AGENT-XXX
|
||||
accept:
|
||||
- '*/*'
|
||||
accept-encoding:
|
||||
- ACCEPT-ENCODING-XXX
|
||||
connection:
|
||||
- keep-alive
|
||||
content-length:
|
||||
- '1964'
|
||||
content-type:
|
||||
- application/json
|
||||
host:
|
||||
- generativelanguage.googleapis.com
|
||||
x-goog-api-client:
|
||||
- google-genai-sdk/1.49.0 gl-python/3.13.3
|
||||
x-goog-api-key:
|
||||
- X-GOOG-API-KEY-XXX
|
||||
method: POST
|
||||
uri: https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent
|
||||
response:
|
||||
body:
|
||||
string: "{\n \"candidates\": [\n {\n \"content\": {\n \"parts\":
|
||||
[\n {\n \"functionCall\": {\n \"name\": \"parallel_local_search_one\",\n
|
||||
\ \"args\": {\n \"query\": \"latest OpenAI model
|
||||
release notes\"\n }\n },\n \"thoughtSignature\":
|
||||
\"CuMEAb4+9vu1V1iOC9o/a8+jQqow8F4RTrjlnjnDCwsisMHLLJ+Wj3pZxbFDeIjCJe9pa6+14InyYHh/ezgHrv+xPGIJtX9pJQatDCBAfCmcZ3fDipVIMAHLcl0Q660EVuZ+vRgvNhPSau+uSN9u303wJsaKvdzOQnfww2LfLtJMNtOhSHfkfhfw2bkBOtMa5/FuLqKSr6m94dSdE7HShR6+jLMLbiSXkBLWsRp0jGl85Wvd0hoA7dUyq+uIuyOBr5Myo9uMrLbxfnrRRbPMorOpYTCmHK0HE8mEBRjzh1hNwcBcfRL0VcgA2UnBIurStIeVbq51BJQ1UOq6r1wVi50Wdh1GjIQ/iN9C15T1Ql3adjom5QbmY+XY08RJOiNyVplh1YQ0qlWCVHEpueEfdzcIB+BUauVrLNqBcBr5g6ekO5QZCAdt7PLerQU8jhKjDQy367jCKQyaHir0GmAISS8RlZ8tkLKNZlZhd11D76ui6X8ep9yznViBbqH0AS1R2hMm+ielMVFjhidglTMjqB0X+yk1K2eZXkc+R/xsXRPlnlZWRygnV+IbU8RAnZWtneM464Wccmc1scfF45GKiji5bLYO7Zx+ZF8mSLcQaC8M3z121D6VbFonhaIdkJ3Wb7nI2vEyxFjdinVk3/P0zL8nu3nHeqQviTrQIoHMsZk0yPyqu9NWxg3wGJL5pbcaQh87ROQuTsInkuzzEr0QMzjw9W5iquhMh4/Wy/OKXAgf3maQB9Jb4HoHZlc0io+KYqewFSVx2BvqXbqJbIrTkTo6XRTbK7dkwlCbMmE1wKIwjrrzZQI=\"\n
|
||||
\ },\n {\n \"functionCall\": {\n \"name\":
|
||||
\"parallel_local_search_two\",\n \"args\": {\n \"query\":
|
||||
\"latest Anthropic model release notes\"\n }\n }\n
|
||||
\ },\n {\n \"functionCall\": {\n \"name\":
|
||||
\"parallel_local_search_three\",\n \"args\": {\n \"query\":
|
||||
\"latest Gemini model release notes\"\n }\n }\n }\n
|
||||
\ ],\n \"role\": \"model\"\n },\n \"finishReason\":
|
||||
\"STOP\",\n \"index\": 0,\n \"finishMessage\": \"Model generated
|
||||
function call(s).\"\n }\n ],\n \"usageMetadata\": {\n \"promptTokenCount\":
|
||||
327,\n \"candidatesTokenCount\": 70,\n \"totalTokenCount\": 536,\n \"promptTokensDetails\":
|
||||
[\n {\n \"modality\": \"TEXT\",\n \"tokenCount\": 327\n
|
||||
\ }\n ],\n \"thoughtsTokenCount\": 139\n },\n \"modelVersion\":
|
||||
\"gemini-2.5-flash\",\n \"responseId\": \"ZVKWabziF7bcjMcP3r2SuAg\"\n}\n"
|
||||
headers:
|
||||
Alt-Svc:
|
||||
- h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
|
||||
Content-Type:
|
||||
- application/json; charset=UTF-8
|
||||
Date:
|
||||
- Wed, 18 Feb 2026 23:59:34 GMT
|
||||
Server:
|
||||
- scaffolding on HTTPServer2
|
||||
Server-Timing:
|
||||
- gfet4t7; dur=1262
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
Vary:
|
||||
- Origin
|
||||
- X-Origin
|
||||
- Referer
|
||||
X-Content-Type-Options:
|
||||
- X-CONTENT-TYPE-XXX
|
||||
X-Frame-Options:
|
||||
- X-FRAME-OPTIONS-XXX
|
||||
X-XSS-Protection:
|
||||
- '0'
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: '{"contents": [{"parts": [{"text": "\nCurrent Task: This is a tool-calling
|
||||
compliance test. In your next assistant turn, emit exactly 3 tool calls in the
|
||||
same response (parallel tool calls), in this order: 1) parallel_local_search_one(query=''latest
|
||||
OpenAI model release notes''), 2) parallel_local_search_two(query=''latest Anthropic
|
||||
model release notes''), 3) parallel_local_search_three(query=''latest Gemini
|
||||
model release notes''). Do not call any other tools and do not answer before
|
||||
those 3 tool calls are emitted. After the tool results return, provide a one
|
||||
paragraph summary.\n\nThis is the expected criteria for your final answer: A
|
||||
one sentence summary of both tool outputs\nyou MUST return the actual complete
|
||||
content as the final answer, not a summary."}], "role": "user"}, {"parts": [{"functionCall":
|
||||
{"args": {"query": "latest OpenAI model release notes"}, "name": "parallel_local_search_one"}},
|
||||
{"functionCall": {"args": {"query": "latest Anthropic model release notes"},
|
||||
"name": "parallel_local_search_two"}}, {"functionCall": {"args": {"query": "latest
|
||||
Gemini model release notes"}, "name": "parallel_local_search_three"}}], "role":
|
||||
"model"}, {"parts": [{"functionResponse": {"name": "parallel_local_search_one",
|
||||
"response": {"result": "[one] latest OpenAI model release notes"}}}], "role":
|
||||
"user"}, {"parts": [{"functionResponse": {"name": "parallel_local_search_two",
|
||||
"response": {"result": "[two] latest Anthropic model release notes"}}}], "role":
|
||||
"user"}, {"parts": [{"functionResponse": {"name": "parallel_local_search_three",
|
||||
"response": {"result": "[three] latest Gemini model release notes"}}}], "role":
|
||||
"user"}, {"parts": [{"text": "Analyze the tool result. If requirements are met,
|
||||
provide the Final Answer. Otherwise, call the next tool. Deliver only the answer
|
||||
without meta-commentary."}], "role": "user"}], "systemInstruction": {"parts":
|
||||
[{"text": "You are Parallel Tool Agent. You follow tool instructions precisely.\nYour
|
||||
personal goal is: Use both tools exactly as instructed"}], "role": "user"},
|
||||
"tools": [{"functionDeclarations": [{"description": "Local search tool #1 for
|
||||
concurrency testing.", "name": "parallel_local_search_one", "parameters_json_schema":
|
||||
{"properties": {"query": {"description": "Search query", "title": "Query", "type":
|
||||
"string"}}, "required": ["query"], "type": "object", "additionalProperties":
|
||||
false}}, {"description": "Local search tool #2 for concurrency testing.", "name":
|
||||
"parallel_local_search_two", "parameters_json_schema": {"properties": {"query":
|
||||
{"description": "Search query", "title": "Query", "type": "string"}}, "required":
|
||||
["query"], "type": "object", "additionalProperties": false}}, {"description":
|
||||
"Local search tool #3 for concurrency testing.", "name": "parallel_local_search_three",
|
||||
"parameters_json_schema": {"properties": {"query": {"description": "Search query",
|
||||
"title": "Query", "type": "string"}}, "required": ["query"], "type": "object",
|
||||
"additionalProperties": false}}]}], "generationConfig": {"stopSequences": ["\nObservation:"]}}'
|
||||
headers:
|
||||
User-Agent:
|
||||
- X-USER-AGENT-XXX
|
||||
accept:
|
||||
- '*/*'
|
||||
accept-encoding:
|
||||
- ACCEPT-ENCODING-XXX
|
||||
connection:
|
||||
- keep-alive
|
||||
content-length:
|
||||
- '3014'
|
||||
content-type:
|
||||
- application/json
|
||||
host:
|
||||
- generativelanguage.googleapis.com
|
||||
x-goog-api-client:
|
||||
- google-genai-sdk/1.49.0 gl-python/3.13.3
|
||||
x-goog-api-key:
|
||||
- X-GOOG-API-KEY-XXX
|
||||
method: POST
|
||||
uri: https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent
|
||||
response:
|
||||
body:
|
||||
string: "{\n \"candidates\": [\n {\n \"content\": {\n \"parts\":
|
||||
[\n {\n \"text\": \"The search results indicate the latest
|
||||
model release notes for OpenAI, Anthropic, and Gemini are: [one] latest OpenAI
|
||||
model release notes[two] latest Anthropic model release notes[three] latest
|
||||
Gemini model release notes.\",\n \"thoughtSignature\": \"CsUPAb4+9vs4hkuatQAakl1FSHx5DIde9nHYobJdlWs2HEzES9gHn7uwjMIlFPTzJUbnZqxpAK93hqsCofdfGANr8dwK+/IbZAiMSikpAq2ZjEbWADjfalU3ke4LcQMh6TEYFVGz1QCinjne3jZx5jOVaL8YdAtjOYnBZWA6KqdvfKjD7+Ct/BLoEqvu4LW6kxhXQgcV+D3M1QxGlr1dxpajj4wyYFI9LXchE2vCdAMPYTkPQ4WPbS3xjz0jJb6qFAwwg+BY5kGemkWWVHsvq28t09pd7FEH0bod5cEpR65qEefpJfhHsXYqmOwHDkfNePYnYC+5qmn7kvkN+fhF41SoMRZahMZGDjIo+q6vvru3eXKmZiuLsrh8AqQIks/4S3sSuxt16ogYKE+LlFxml2ygXFPww59nRAtc+xK6VW8jB2vyv9Eo5cpnG9ZBv1dOznJnmj4AWA1ddMlp+yq8AdaboTSo5dysYMwFcSXS3kuU+xi92dC+7GqZZbDr5frvnc+MnSuzYwHhNjSQqvTo5DKGit53zDwlFJT74kLBXk36BOFQp4xlfs+BpKkw11bow6qQoTvC68D023ZHami+McO1WYBDoO5CrDoosU8fAYljqaGArBoMlssF4O7VKHEaEbEZnYCr0Wxo6XP/mtPIpHQE4OyCz/GAJSJtQv1hO7DNCMzpSpkLyuemB1SOZGl3mlLQhosh3TAGP0xgqmHpKccdCSWoXGWjO48VluFuV9E1FwW1Xi++XhMRcUaljJXPZaNVjGcAG1uAxeVkUMsY8tBvQ0vaumUK2jkzbyQTWeStEWwl1yKmklI8JDXske/k6tYJOyF+8t0mF7oCEqNHSNicj7TomihpPlVjNl1Mm4l5fvwlKtAPJwiKrchCunlZB3uGN1AR0h0Hvznffutc/lV/FWFbNgFAaNJZKRs40vMk1xmRZyH2rs+Ob2fZriQ3BSwzzNeiwDLXxm0m/ytOai+K9ObFuC/IEh5fJfvQbNeo3TmiCAMCZPNXMDtlOyLqQzzKwmMFH4c53Ol+kkTiuAKECNQR1dOCufAL0U5lzEUFRxFvOq67lp6xqG8m+WzCIkbnF8QyJHfujtXVMJACaevUkM7+kAVyTwETEKQsanp0tBwzV42ieChp/h7pivcC++cFXdSG5dvR94BgkHmtpC9+jfNH32RREPLuyWfU5aBXiOkxjRs9fDexAFjrkGjM18I+jqHZNeuUR20BKe2jFsU8xJS3Fa4eXabm/YPL1t8R5jr572Ch/r4bspFp8MQ5RcFo8Nn/HiBmW8uZ2BcLEY1RPWUBvxVhfvh/hNxaRKu21x8vGz72RoiNuOjNbeADYAaBJqBGLp0MALxZ/rnXPzDLQUt6Mv07fWHAZr5p3r/skleot25lr2Tcl4qJCPM4/cfs6U0x4CY26ktBiCs4bWKqSEV1Q05nf5kpxVOIRSTgxqFOj/rWIAF3uw7mvsuRKd3YXILV5OrvEoETdQvf7BdYPbQbIQYDf7DBKhf51O8RKQgcfl6mVQswamdJ+PyqLbozTkFCjXMKI0PwJdy8tfKfCeeEe0TbOXSfeTczKQkL8WyWkBg4tS81JnWAVzfVlNjbvo/fk+wv7FyfJJS1HJGlxZ0kUlWi1369rSlldYPoSqopuekOxtYnpYpz92y/jVLNQXE1IVLqWYh9o3gTwjeyaHG7fCaWF2QRGrCUvejT8eJjevhj/sgadjPVcEP5o7Zcw5yTBCgc0+FX1j5KpCmfZ/dVvT4iIX8bOkhxjHQ8ifOx39BMM4EObgCA+g+BFN+Ra7kOf4hJ6tPNhqvJa4E4fyISlVrRiBqSt59ZkuLyWuY9SYy0nvbklP30WDUHSAvcuEwVMSuT524afHISfO/+tSgE7JAKzEPSOoVO3Z5NS9kcAqHuBSe/LL4XJbCKF9Oggm9/gwdAulnBANd4ydQ/raTPE/QUu/CGqqGhBd+wo8x0Jg/BMZWkwhz0fEzsh+OjnrEkHv4QIqZ9v/j1Rv9uc+cDeK7eGi62okGLrPFX2pNQtsZRdUM9aBSlTBUVSdCDpkvieENzLnR257EDZy1EV2HxGRfOFZVVdaW1n8XvL73pcFoQ5XABpfYuigOS8i4S8g43Qfe77GosnuXR5rcJCrL03q3hptb97K5ysKFLgumsaaWo92MBhZYKvQ6SwStgyWRlb22uQGQJYsS8OTD/uVNiQzFjOMsR/l71c9RI1Eb7SQJT6WWvL1YhA7sQw/lQf8soLKfWshoky6mMrGopjRak8xHpJe5VWbqK8PK6iXDd403JrHICyh4M3FpEja3eX2V3SN6U+EgIWKIE8lE/iQZakhLtG2KL7nNQy/cksxzIh5ElQCe5NkrQZO0fai6ek8qwbmz07RVg2FknD7F2hvmxZBqoJSXhsFVn/9+fnkcsZekEtUevFmlQQNspPc63XgO0XmpTye9uM/BbTEsNEWeHSFZTEQLLx1l+pgwsYO3NlNSIUN24/GIR7JrZFG4fAoljkDKjhrYQzr1Fiy3t5G+CmadZ0TcjRQQdDw36ETlf7cizcrQc4FNtnx5rNWEaf54vUvlsd2DD19UIkzP9omITsiuNPPcUNq0A6v1TkgnSNYfhb26nxJIg34r8MmCAhWzB2eCy54gvOHDGLFAwfFZrQdvl\"\n
|
||||
\ }\n ],\n \"role\": \"model\"\n },\n \"finishReason\":
|
||||
\"STOP\",\n \"index\": 0\n }\n ],\n \"usageMetadata\": {\n \"promptTokenCount\":
|
||||
504,\n \"candidatesTokenCount\": 45,\n \"totalTokenCount\": 973,\n \"promptTokensDetails\":
|
||||
[\n {\n \"modality\": \"TEXT\",\n \"tokenCount\": 504\n
|
||||
\ }\n ],\n \"thoughtsTokenCount\": 424\n },\n \"modelVersion\":
|
||||
\"gemini-2.5-flash\",\n \"responseId\": \"Z1KWaYbTKZvnjMcP7piEoAg\"\n}\n"
|
||||
headers:
|
||||
Alt-Svc:
|
||||
- h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
|
||||
Content-Type:
|
||||
- application/json; charset=UTF-8
|
||||
Date:
|
||||
- Wed, 18 Feb 2026 23:59:37 GMT
|
||||
Server:
|
||||
- scaffolding on HTTPServer2
|
||||
Server-Timing:
|
||||
- gfet4t7; dur=2283
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
Vary:
|
||||
- Origin
|
||||
- X-Origin
|
||||
- Referer
|
||||
X-Content-Type-Options:
|
||||
- X-CONTENT-TYPE-XXX
|
||||
X-Frame-Options:
|
||||
- X-FRAME-OPTIONS-XXX
|
||||
X-XSS-Protection:
|
||||
- '0'
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
version: 1
|
||||
@@ -5,9 +5,9 @@ interactions:
|
||||
calculations"},{"role":"user","content":"\nCurrent Task: Calculate what is 15
|
||||
* 8\n\nThis is the expected criteria for your final answer: The result of the
|
||||
calculation\nyou MUST return the actual complete content as the final answer,
|
||||
not a summary.\n\nThis is VERY important to you, your job depends on it!"}],"model":"gpt-4o-mini","tool_choice":"auto","tools":[{"type":"function","function":{"name":"calculator","description":"Perform
|
||||
mathematical calculations. Use this for any math operations.","parameters":{"properties":{"expression":{"description":"Mathematical
|
||||
expression to evaluate","title":"Expression","type":"string"}},"required":["expression"],"type":"object"}}}]}'
|
||||
not a summary."}],"model":"gpt-5-nano","tool_choice":"auto","tools":[{"type":"function","function":{"name":"calculator","description":"Perform
|
||||
mathematical calculations. Use this for any math operations.","strict":true,"parameters":{"properties":{"expression":{"description":"Mathematical
|
||||
expression to evaluate","title":"Expression","type":"string"}},"required":["expression"],"type":"object","additionalProperties":false}}}]}'
|
||||
headers:
|
||||
User-Agent:
|
||||
- X-USER-AGENT-XXX
|
||||
@@ -20,7 +20,7 @@ interactions:
|
||||
connection:
|
||||
- keep-alive
|
||||
content-length:
|
||||
- '829'
|
||||
- '813'
|
||||
content-type:
|
||||
- application/json
|
||||
host:
|
||||
@@ -47,140 +47,17 @@ interactions:
|
||||
uri: https://api.openai.com/v1/chat/completions
|
||||
response:
|
||||
body:
|
||||
string: "{\n \"id\": \"chatcmpl-D0vm7joOuDBPcMpfmOnftOoTCPtc8\",\n \"object\":
|
||||
\"chat.completion\",\n \"created\": 1769114459,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n
|
||||
\ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\":
|
||||
\"assistant\",\n \"content\": null,\n \"tool_calls\": [\n {\n
|
||||
\ \"id\": \"call_G73UZDvL4wC9EEdvm1UcRIRM\",\n \"type\":
|
||||
\"function\",\n \"function\": {\n \"name\": \"calculator\",\n
|
||||
\ \"arguments\": \"{\\\"expression\\\":\\\"15 * 8\\\"}\"\n }\n
|
||||
\ }\n ],\n \"refusal\": null,\n \"annotations\":
|
||||
[]\n },\n \"logprobs\": null,\n \"finish_reason\": \"tool_calls\"\n
|
||||
\ }\n ],\n \"usage\": {\n \"prompt_tokens\": 137,\n \"completion_tokens\":
|
||||
17,\n \"total_tokens\": 154,\n \"prompt_tokens_details\": {\n \"cached_tokens\":
|
||||
0,\n \"audio_tokens\": 0\n },\n \"completion_tokens_details\":
|
||||
{\n \"reasoning_tokens\": 0,\n \"audio_tokens\": 0,\n \"accepted_prediction_tokens\":
|
||||
0,\n \"rejected_prediction_tokens\": 0\n }\n },\n \"service_tier\":
|
||||
\"default\",\n \"system_fingerprint\": \"fp_c4585b5b9c\"\n}\n"
|
||||
headers:
|
||||
CF-RAY:
|
||||
- CF-RAY-XXX
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Thu, 22 Jan 2026 20:40:59 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- SET-COOKIE-XXX
|
||||
Strict-Transport-Security:
|
||||
- STS-XXX
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
X-Content-Type-Options:
|
||||
- X-CONTENT-TYPE-XXX
|
||||
access-control-expose-headers:
|
||||
- ACCESS-CONTROL-XXX
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
cf-cache-status:
|
||||
- DYNAMIC
|
||||
openai-organization:
|
||||
- OPENAI-ORG-XXX
|
||||
openai-processing-ms:
|
||||
- '761'
|
||||
openai-project:
|
||||
- OPENAI-PROJECT-XXX
|
||||
openai-version:
|
||||
- '2020-10-01'
|
||||
x-envoy-upstream-service-time:
|
||||
- '1080'
|
||||
x-openai-proxy-wasm:
|
||||
- v0.1
|
||||
x-ratelimit-limit-requests:
|
||||
- X-RATELIMIT-LIMIT-REQUESTS-XXX
|
||||
x-ratelimit-limit-tokens:
|
||||
- X-RATELIMIT-LIMIT-TOKENS-XXX
|
||||
x-ratelimit-remaining-requests:
|
||||
- X-RATELIMIT-REMAINING-REQUESTS-XXX
|
||||
x-ratelimit-remaining-tokens:
|
||||
- X-RATELIMIT-REMAINING-TOKENS-XXX
|
||||
x-ratelimit-reset-requests:
|
||||
- X-RATELIMIT-RESET-REQUESTS-XXX
|
||||
x-ratelimit-reset-tokens:
|
||||
- X-RATELIMIT-RESET-TOKENS-XXX
|
||||
x-request-id:
|
||||
- X-REQUEST-ID-XXX
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: '{"messages":[{"role":"system","content":"You are Math Assistant. You are
|
||||
a helpful math assistant.\nYour personal goal is: Help users with mathematical
|
||||
calculations"},{"role":"user","content":"\nCurrent Task: Calculate what is 15
|
||||
* 8\n\nThis is the expected criteria for your final answer: The result of the
|
||||
calculation\nyou MUST return the actual complete content as the final answer,
|
||||
not a summary.\n\nThis is VERY important to you, your job depends on it!"},{"role":"assistant","content":null,"tool_calls":[{"id":"call_G73UZDvL4wC9EEdvm1UcRIRM","type":"function","function":{"name":"calculator","arguments":"{\"expression\":\"15
|
||||
* 8\"}"}}]},{"role":"tool","tool_call_id":"call_G73UZDvL4wC9EEdvm1UcRIRM","content":"The
|
||||
result of 15 * 8 is 120"},{"role":"user","content":"Analyze the tool result.
|
||||
If requirements are met, provide the Final Answer. Otherwise, call the next
|
||||
tool. Deliver only the answer without meta-commentary."}],"model":"gpt-4o-mini","tool_choice":"auto","tools":[{"type":"function","function":{"name":"calculator","description":"Perform
|
||||
mathematical calculations. Use this for any math operations.","parameters":{"properties":{"expression":{"description":"Mathematical
|
||||
expression to evaluate","title":"Expression","type":"string"}},"required":["expression"],"type":"object"}}}]}'
|
||||
headers:
|
||||
User-Agent:
|
||||
- X-USER-AGENT-XXX
|
||||
accept:
|
||||
- application/json
|
||||
accept-encoding:
|
||||
- ACCEPT-ENCODING-XXX
|
||||
authorization:
|
||||
- AUTHORIZATION-XXX
|
||||
connection:
|
||||
- keep-alive
|
||||
content-length:
|
||||
- '1299'
|
||||
content-type:
|
||||
- application/json
|
||||
cookie:
|
||||
- COOKIE-XXX
|
||||
host:
|
||||
- api.openai.com
|
||||
x-stainless-arch:
|
||||
- X-STAINLESS-ARCH-XXX
|
||||
x-stainless-async:
|
||||
- 'false'
|
||||
x-stainless-lang:
|
||||
- python
|
||||
x-stainless-os:
|
||||
- X-STAINLESS-OS-XXX
|
||||
x-stainless-package-version:
|
||||
- 1.83.0
|
||||
x-stainless-read-timeout:
|
||||
- X-STAINLESS-READ-TIMEOUT-XXX
|
||||
x-stainless-retry-count:
|
||||
- '0'
|
||||
x-stainless-runtime:
|
||||
- CPython
|
||||
x-stainless-runtime-version:
|
||||
- 3.13.3
|
||||
method: POST
|
||||
uri: https://api.openai.com/v1/chat/completions
|
||||
response:
|
||||
body:
|
||||
string: "{\n \"id\": \"chatcmpl-D0vm8mUnzLxu9pf1rc7MODkrMsCmf\",\n \"object\":
|
||||
\"chat.completion\",\n \"created\": 1769114460,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n
|
||||
string: "{\n \"id\": \"chatcmpl-DAlG9W2mJYuOgpf3FwCRgbqaiHWf3\",\n \"object\":
|
||||
\"chat.completion\",\n \"created\": 1771457317,\n \"model\": \"gpt-5-nano-2025-08-07\",\n
|
||||
\ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\":
|
||||
\"assistant\",\n \"content\": \"120\",\n \"refusal\": null,\n
|
||||
\ \"annotations\": []\n },\n \"logprobs\": null,\n \"finish_reason\":
|
||||
\"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 207,\n \"completion_tokens\":
|
||||
2,\n \"total_tokens\": 209,\n \"prompt_tokens_details\": {\n \"cached_tokens\":
|
||||
\ \"annotations\": []\n },\n \"finish_reason\": \"stop\"\n
|
||||
\ }\n ],\n \"usage\": {\n \"prompt_tokens\": 208,\n \"completion_tokens\":
|
||||
138,\n \"total_tokens\": 346,\n \"prompt_tokens_details\": {\n \"cached_tokens\":
|
||||
0,\n \"audio_tokens\": 0\n },\n \"completion_tokens_details\":
|
||||
{\n \"reasoning_tokens\": 0,\n \"audio_tokens\": 0,\n \"accepted_prediction_tokens\":
|
||||
{\n \"reasoning_tokens\": 128,\n \"audio_tokens\": 0,\n \"accepted_prediction_tokens\":
|
||||
0,\n \"rejected_prediction_tokens\": 0\n }\n },\n \"service_tier\":
|
||||
\"default\",\n \"system_fingerprint\": \"fp_c4585b5b9c\"\n}\n"
|
||||
\"default\",\n \"system_fingerprint\": null\n}\n"
|
||||
headers:
|
||||
CF-RAY:
|
||||
- CF-RAY-XXX
|
||||
@@ -189,7 +66,7 @@ interactions:
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Thu, 22 Jan 2026 20:41:00 GMT
|
||||
- Wed, 18 Feb 2026 23:28:39 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Strict-Transport-Security:
|
||||
@@ -207,13 +84,13 @@ interactions:
|
||||
openai-organization:
|
||||
- OPENAI-ORG-XXX
|
||||
openai-processing-ms:
|
||||
- '262'
|
||||
- '1869'
|
||||
openai-project:
|
||||
- OPENAI-PROJECT-XXX
|
||||
openai-version:
|
||||
- '2020-10-01'
|
||||
x-envoy-upstream-service-time:
|
||||
- '496'
|
||||
set-cookie:
|
||||
- SET-COOKIE-XXX
|
||||
x-openai-proxy-wasm:
|
||||
- v0.1
|
||||
x-ratelimit-limit-requests:
|
||||
|
||||
@@ -0,0 +1,265 @@
|
||||
interactions:
|
||||
- request:
|
||||
body: '{"messages":[{"role":"system","content":"You are Parallel Tool Agent. You
|
||||
follow tool instructions precisely.\nYour personal goal is: Use both tools exactly
|
||||
as instructed"},{"role":"user","content":"\nCurrent Task: This is a tool-calling
|
||||
compliance test. In your next assistant turn, emit exactly 3 tool calls in the
|
||||
same response (parallel tool calls), in this order: 1) parallel_local_search_one(query=''latest
|
||||
OpenAI model release notes''), 2) parallel_local_search_two(query=''latest Anthropic
|
||||
model release notes''), 3) parallel_local_search_three(query=''latest Gemini
|
||||
model release notes''). Do not call any other tools and do not answer before
|
||||
those 3 tool calls are emitted. After the tool results return, provide a one
|
||||
paragraph summary."}],"model":"gpt-4o-mini","tool_choice":"auto","tools":[{"type":"function","function":{"name":"parallel_local_search_one","description":"Local
|
||||
search tool #1 for concurrency testing.","strict":true,"parameters":{"properties":{"query":{"description":"Search
|
||||
query","title":"Query","type":"string"}},"required":["query"],"type":"object","additionalProperties":false}}},{"type":"function","function":{"name":"parallel_local_search_two","description":"Local
|
||||
search tool #2 for concurrency testing.","strict":true,"parameters":{"properties":{"query":{"description":"Search
|
||||
query","title":"Query","type":"string"}},"required":["query"],"type":"object","additionalProperties":false}}},{"type":"function","function":{"name":"parallel_local_search_three","description":"Local
|
||||
search tool #3 for concurrency testing.","strict":true,"parameters":{"properties":{"query":{"description":"Search
|
||||
query","title":"Query","type":"string"}},"required":["query"],"type":"object","additionalProperties":false}}}]}'
|
||||
headers:
|
||||
User-Agent:
|
||||
- X-USER-AGENT-XXX
|
||||
accept:
|
||||
- application/json
|
||||
accept-encoding:
|
||||
- ACCEPT-ENCODING-XXX
|
||||
authorization:
|
||||
- AUTHORIZATION-XXX
|
||||
connection:
|
||||
- keep-alive
|
||||
content-length:
|
||||
- '1733'
|
||||
content-type:
|
||||
- application/json
|
||||
host:
|
||||
- api.openai.com
|
||||
x-stainless-arch:
|
||||
- X-STAINLESS-ARCH-XXX
|
||||
x-stainless-async:
|
||||
- 'false'
|
||||
x-stainless-lang:
|
||||
- python
|
||||
x-stainless-os:
|
||||
- X-STAINLESS-OS-XXX
|
||||
x-stainless-package-version:
|
||||
- 1.83.0
|
||||
x-stainless-read-timeout:
|
||||
- X-STAINLESS-READ-TIMEOUT-XXX
|
||||
x-stainless-retry-count:
|
||||
- '0'
|
||||
x-stainless-runtime:
|
||||
- CPython
|
||||
x-stainless-runtime-version:
|
||||
- 3.13.3
|
||||
method: POST
|
||||
uri: https://api.openai.com/v1/chat/completions
|
||||
response:
|
||||
body:
|
||||
string: "{\n \"id\": \"chatcmpl-DAldZHfQGVcV3FNwAJAtNooU3PAU7\",\n \"object\":
|
||||
\"chat.completion\",\n \"created\": 1771458769,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n
|
||||
\ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\":
|
||||
\"assistant\",\n \"content\": null,\n \"tool_calls\": [\n {\n
|
||||
\ \"id\": \"call_kz1qLLRsugXwWiQMeH9oFAep\",\n \"type\":
|
||||
\"function\",\n \"function\": {\n \"name\": \"parallel_local_search_one\",\n
|
||||
\ \"arguments\": \"{\\\"query\\\": \\\"latest OpenAI model release
|
||||
notes\\\"}\"\n }\n },\n {\n \"id\":
|
||||
\"call_yNouGq1Kv6P5W9fhTng6acZi\",\n \"type\": \"function\",\n
|
||||
\ \"function\": {\n \"name\": \"parallel_local_search_two\",\n
|
||||
\ \"arguments\": \"{\\\"query\\\": \\\"latest Anthropic model
|
||||
release notes\\\"}\"\n }\n },\n {\n \"id\":
|
||||
\"call_O7MqnuniDmyT6a0BS31GTunB\",\n \"type\": \"function\",\n
|
||||
\ \"function\": {\n \"name\": \"parallel_local_search_three\",\n
|
||||
\ \"arguments\": \"{\\\"query\\\": \\\"latest Gemini model release
|
||||
notes\\\"}\"\n }\n }\n ],\n \"refusal\":
|
||||
null,\n \"annotations\": []\n },\n \"logprobs\": null,\n
|
||||
\ \"finish_reason\": \"tool_calls\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\":
|
||||
259,\n \"completion_tokens\": 78,\n \"total_tokens\": 337,\n \"prompt_tokens_details\":
|
||||
{\n \"cached_tokens\": 0,\n \"audio_tokens\": 0\n },\n \"completion_tokens_details\":
|
||||
{\n \"reasoning_tokens\": 0,\n \"audio_tokens\": 0,\n \"accepted_prediction_tokens\":
|
||||
0,\n \"rejected_prediction_tokens\": 0\n }\n },\n \"service_tier\":
|
||||
\"default\",\n \"system_fingerprint\": \"fp_414ba99a04\"\n}\n"
|
||||
headers:
|
||||
CF-RAY:
|
||||
- CF-RAY-XXX
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Wed, 18 Feb 2026 23:52:50 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Strict-Transport-Security:
|
||||
- STS-XXX
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
X-Content-Type-Options:
|
||||
- X-CONTENT-TYPE-XXX
|
||||
access-control-expose-headers:
|
||||
- ACCESS-CONTROL-XXX
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
cf-cache-status:
|
||||
- DYNAMIC
|
||||
openai-organization:
|
||||
- OPENAI-ORG-XXX
|
||||
openai-processing-ms:
|
||||
- '1418'
|
||||
openai-project:
|
||||
- OPENAI-PROJECT-XXX
|
||||
openai-version:
|
||||
- '2020-10-01'
|
||||
set-cookie:
|
||||
- SET-COOKIE-XXX
|
||||
x-openai-proxy-wasm:
|
||||
- v0.1
|
||||
x-ratelimit-limit-requests:
|
||||
- X-RATELIMIT-LIMIT-REQUESTS-XXX
|
||||
x-ratelimit-limit-tokens:
|
||||
- X-RATELIMIT-LIMIT-TOKENS-XXX
|
||||
x-ratelimit-remaining-requests:
|
||||
- X-RATELIMIT-REMAINING-REQUESTS-XXX
|
||||
x-ratelimit-remaining-tokens:
|
||||
- X-RATELIMIT-REMAINING-TOKENS-XXX
|
||||
x-ratelimit-reset-requests:
|
||||
- X-RATELIMIT-RESET-REQUESTS-XXX
|
||||
x-ratelimit-reset-tokens:
|
||||
- X-RATELIMIT-RESET-TOKENS-XXX
|
||||
x-request-id:
|
||||
- X-REQUEST-ID-XXX
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: '{"messages":[{"role":"system","content":"You are Parallel Tool Agent. You
|
||||
follow tool instructions precisely.\nYour personal goal is: Use both tools exactly
|
||||
as instructed"},{"role":"user","content":"\nCurrent Task: This is a tool-calling
|
||||
compliance test. In your next assistant turn, emit exactly 3 tool calls in the
|
||||
same response (parallel tool calls), in this order: 1) parallel_local_search_one(query=''latest
|
||||
OpenAI model release notes''), 2) parallel_local_search_two(query=''latest Anthropic
|
||||
model release notes''), 3) parallel_local_search_three(query=''latest Gemini
|
||||
model release notes''). Do not call any other tools and do not answer before
|
||||
those 3 tool calls are emitted. After the tool results return, provide a one
|
||||
paragraph summary."},{"role":"assistant","content":null,"tool_calls":[{"id":"call_kz1qLLRsugXwWiQMeH9oFAep","type":"function","function":{"name":"parallel_local_search_one","arguments":"{\"query\":
|
||||
\"latest OpenAI model release notes\"}"}},{"id":"call_yNouGq1Kv6P5W9fhTng6acZi","type":"function","function":{"name":"parallel_local_search_two","arguments":"{\"query\":
|
||||
\"latest Anthropic model release notes\"}"}},{"id":"call_O7MqnuniDmyT6a0BS31GTunB","type":"function","function":{"name":"parallel_local_search_three","arguments":"{\"query\":
|
||||
\"latest Gemini model release notes\"}"}}]},{"role":"tool","tool_call_id":"call_kz1qLLRsugXwWiQMeH9oFAep","name":"parallel_local_search_one","content":"[one]
|
||||
latest OpenAI model release notes"},{"role":"tool","tool_call_id":"call_yNouGq1Kv6P5W9fhTng6acZi","name":"parallel_local_search_two","content":"[two]
|
||||
latest Anthropic model release notes"},{"role":"tool","tool_call_id":"call_O7MqnuniDmyT6a0BS31GTunB","name":"parallel_local_search_three","content":"[three]
|
||||
latest Gemini model release notes"}],"model":"gpt-4o-mini","tool_choice":"auto","tools":[{"type":"function","function":{"name":"parallel_local_search_one","description":"Local
|
||||
search tool #1 for concurrency testing.","strict":true,"parameters":{"properties":{"query":{"description":"Search
|
||||
query","title":"Query","type":"string"}},"required":["query"],"type":"object","additionalProperties":false}}},{"type":"function","function":{"name":"parallel_local_search_two","description":"Local
|
||||
search tool #2 for concurrency testing.","strict":true,"parameters":{"properties":{"query":{"description":"Search
|
||||
query","title":"Query","type":"string"}},"required":["query"],"type":"object","additionalProperties":false}}},{"type":"function","function":{"name":"parallel_local_search_three","description":"Local
|
||||
search tool #3 for concurrency testing.","strict":true,"parameters":{"properties":{"query":{"description":"Search
|
||||
query","title":"Query","type":"string"}},"required":["query"],"type":"object","additionalProperties":false}}}]}'
|
||||
headers:
|
||||
User-Agent:
|
||||
- X-USER-AGENT-XXX
|
||||
accept:
|
||||
- application/json
|
||||
accept-encoding:
|
||||
- ACCEPT-ENCODING-XXX
|
||||
authorization:
|
||||
- AUTHORIZATION-XXX
|
||||
connection:
|
||||
- keep-alive
|
||||
content-length:
|
||||
- '2756'
|
||||
content-type:
|
||||
- application/json
|
||||
cookie:
|
||||
- COOKIE-XXX
|
||||
host:
|
||||
- api.openai.com
|
||||
x-stainless-arch:
|
||||
- X-STAINLESS-ARCH-XXX
|
||||
x-stainless-async:
|
||||
- 'false'
|
||||
x-stainless-lang:
|
||||
- python
|
||||
x-stainless-os:
|
||||
- X-STAINLESS-OS-XXX
|
||||
x-stainless-package-version:
|
||||
- 1.83.0
|
||||
x-stainless-read-timeout:
|
||||
- X-STAINLESS-READ-TIMEOUT-XXX
|
||||
x-stainless-retry-count:
|
||||
- '0'
|
||||
x-stainless-runtime:
|
||||
- CPython
|
||||
x-stainless-runtime-version:
|
||||
- 3.13.3
|
||||
method: POST
|
||||
uri: https://api.openai.com/v1/chat/completions
|
||||
response:
|
||||
body:
|
||||
string: "{\n \"id\": \"chatcmpl-DAldbawkFNpOeXbaJTkTlsSi7OiII\",\n \"object\":
|
||||
\"chat.completion\",\n \"created\": 1771458771,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n
|
||||
\ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\":
|
||||
\"assistant\",\n \"content\": \"The latest release notes for OpenAI,
|
||||
Anthropic, and Gemini models highlight significant updates and improvements
|
||||
in each respective technology. OpenAI's notes detail new features and optimizations
|
||||
that enhance user interaction and performance. Anthropic's release emphasizes
|
||||
their focus on safety and alignment in AI development, showcasing advancements
|
||||
in responsible AI practices. Gemini's notes underline their innovative approaches
|
||||
and cutting-edge functionalities designed to push the boundaries of current
|
||||
AI capabilities.\",\n \"refusal\": null,\n \"annotations\":
|
||||
[]\n },\n \"logprobs\": null,\n \"finish_reason\": \"stop\"\n
|
||||
\ }\n ],\n \"usage\": {\n \"prompt_tokens\": 377,\n \"completion_tokens\":
|
||||
85,\n \"total_tokens\": 462,\n \"prompt_tokens_details\": {\n \"cached_tokens\":
|
||||
0,\n \"audio_tokens\": 0\n },\n \"completion_tokens_details\":
|
||||
{\n \"reasoning_tokens\": 0,\n \"audio_tokens\": 0,\n \"accepted_prediction_tokens\":
|
||||
0,\n \"rejected_prediction_tokens\": 0\n }\n },\n \"service_tier\":
|
||||
\"default\",\n \"system_fingerprint\": \"fp_414ba99a04\"\n}\n"
|
||||
headers:
|
||||
CF-RAY:
|
||||
- CF-RAY-XXX
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Wed, 18 Feb 2026 23:52:53 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Strict-Transport-Security:
|
||||
- STS-XXX
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
X-Content-Type-Options:
|
||||
- X-CONTENT-TYPE-XXX
|
||||
access-control-expose-headers:
|
||||
- ACCESS-CONTROL-XXX
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
cf-cache-status:
|
||||
- DYNAMIC
|
||||
openai-organization:
|
||||
- OPENAI-ORG-XXX
|
||||
openai-processing-ms:
|
||||
- '1755'
|
||||
openai-project:
|
||||
- OPENAI-PROJECT-XXX
|
||||
openai-version:
|
||||
- '2020-10-01'
|
||||
x-openai-proxy-wasm:
|
||||
- v0.1
|
||||
x-ratelimit-limit-requests:
|
||||
- X-RATELIMIT-LIMIT-REQUESTS-XXX
|
||||
x-ratelimit-limit-tokens:
|
||||
- X-RATELIMIT-LIMIT-TOKENS-XXX
|
||||
x-ratelimit-remaining-requests:
|
||||
- X-RATELIMIT-REMAINING-REQUESTS-XXX
|
||||
x-ratelimit-remaining-tokens:
|
||||
- X-RATELIMIT-REMAINING-TOKENS-XXX
|
||||
x-ratelimit-reset-requests:
|
||||
- X-RATELIMIT-RESET-REQUESTS-XXX
|
||||
x-ratelimit-reset-tokens:
|
||||
- X-RATELIMIT-RESET-TOKENS-XXX
|
||||
x-request-id:
|
||||
- X-REQUEST-ID-XXX
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
version: 1
|
||||
@@ -0,0 +1,265 @@
|
||||
interactions:
|
||||
- request:
|
||||
body: '{"messages":[{"role":"system","content":"You are Parallel Tool Agent. You
|
||||
follow tool instructions precisely.\nYour personal goal is: Use both tools exactly
|
||||
as instructed"},{"role":"user","content":"\nCurrent Task: This is a tool-calling
|
||||
compliance test. In your next assistant turn, emit exactly 3 tool calls in the
|
||||
same response (parallel tool calls), in this order: 1) parallel_local_search_one(query=''latest
|
||||
OpenAI model release notes''), 2) parallel_local_search_two(query=''latest Anthropic
|
||||
model release notes''), 3) parallel_local_search_three(query=''latest Gemini
|
||||
model release notes''). Do not call any other tools and do not answer before
|
||||
those 3 tool calls are emitted. After the tool results return, provide a one
|
||||
paragraph summary.\n\nThis is the expected criteria for your final answer: A
|
||||
one sentence summary of both tool outputs\nyou MUST return the actual complete
|
||||
content as the final answer, not a summary."}],"model":"gpt-5-nano","temperature":1,"tool_choice":"auto","tools":[{"type":"function","function":{"name":"parallel_local_search_one","description":"Local
|
||||
search tool #1 for concurrency testing.","strict":true,"parameters":{"properties":{"query":{"description":"Search
|
||||
query","title":"Query","type":"string"}},"required":["query"],"type":"object","additionalProperties":false}}},{"type":"function","function":{"name":"parallel_local_search_two","description":"Local
|
||||
search tool #2 for concurrency testing.","strict":true,"parameters":{"properties":{"query":{"description":"Search
|
||||
query","title":"Query","type":"string"}},"required":["query"],"type":"object","additionalProperties":false}}},{"type":"function","function":{"name":"parallel_local_search_three","description":"Local
|
||||
search tool #3 for concurrency testing.","strict":true,"parameters":{"properties":{"query":{"description":"Search
|
||||
query","title":"Query","type":"string"}},"required":["query"],"type":"object","additionalProperties":false}}}]}'
|
||||
headers:
|
||||
User-Agent:
|
||||
- X-USER-AGENT-XXX
|
||||
accept:
|
||||
- application/json
|
||||
accept-encoding:
|
||||
- ACCEPT-ENCODING-XXX
|
||||
authorization:
|
||||
- AUTHORIZATION-XXX
|
||||
connection:
|
||||
- keep-alive
|
||||
content-length:
|
||||
- '1929'
|
||||
content-type:
|
||||
- application/json
|
||||
host:
|
||||
- api.openai.com
|
||||
x-stainless-arch:
|
||||
- X-STAINLESS-ARCH-XXX
|
||||
x-stainless-async:
|
||||
- 'false'
|
||||
x-stainless-lang:
|
||||
- python
|
||||
x-stainless-os:
|
||||
- X-STAINLESS-OS-XXX
|
||||
x-stainless-package-version:
|
||||
- 1.83.0
|
||||
x-stainless-read-timeout:
|
||||
- X-STAINLESS-READ-TIMEOUT-XXX
|
||||
x-stainless-retry-count:
|
||||
- '0'
|
||||
x-stainless-runtime:
|
||||
- CPython
|
||||
x-stainless-runtime-version:
|
||||
- 3.13.3
|
||||
method: POST
|
||||
uri: https://api.openai.com/v1/chat/completions
|
||||
response:
|
||||
body:
|
||||
string: "{\n \"id\": \"chatcmpl-DAlddfEozIpgleBufPaffZMQWK0Hj\",\n \"object\":
|
||||
\"chat.completion\",\n \"created\": 1771458773,\n \"model\": \"gpt-5-nano-2025-08-07\",\n
|
||||
\ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\":
|
||||
\"assistant\",\n \"content\": null,\n \"tool_calls\": [\n {\n
|
||||
\ \"id\": \"call_Putc2jV5GhiIZMwx8mDcI61Q\",\n \"type\":
|
||||
\"function\",\n \"function\": {\n \"name\": \"parallel_local_search_one\",\n
|
||||
\ \"arguments\": \"{\\\"query\\\": \\\"latest OpenAI model release
|
||||
notes\\\"}\"\n }\n },\n {\n \"id\":
|
||||
\"call_iyjwcvkL3PdoOddxsqkHCT9T\",\n \"type\": \"function\",\n
|
||||
\ \"function\": {\n \"name\": \"parallel_local_search_two\",\n
|
||||
\ \"arguments\": \"{\\\"query\\\": \\\"latest Anthropic model
|
||||
release notes\\\"}\"\n }\n },\n {\n \"id\":
|
||||
\"call_G728RseEU7SbGk5YTiyyp9IH\",\n \"type\": \"function\",\n
|
||||
\ \"function\": {\n \"name\": \"parallel_local_search_three\",\n
|
||||
\ \"arguments\": \"{\\\"query\\\": \\\"latest Gemini model release
|
||||
notes\\\"}\"\n }\n }\n ],\n \"refusal\":
|
||||
null,\n \"annotations\": []\n },\n \"finish_reason\": \"tool_calls\"\n
|
||||
\ }\n ],\n \"usage\": {\n \"prompt_tokens\": 378,\n \"completion_tokens\":
|
||||
1497,\n \"total_tokens\": 1875,\n \"prompt_tokens_details\": {\n \"cached_tokens\":
|
||||
0,\n \"audio_tokens\": 0\n },\n \"completion_tokens_details\":
|
||||
{\n \"reasoning_tokens\": 1408,\n \"audio_tokens\": 0,\n \"accepted_prediction_tokens\":
|
||||
0,\n \"rejected_prediction_tokens\": 0\n }\n },\n \"service_tier\":
|
||||
\"default\",\n \"system_fingerprint\": null\n}\n"
|
||||
headers:
|
||||
CF-RAY:
|
||||
- CF-RAY-XXX
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Wed, 18 Feb 2026 23:53:08 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Strict-Transport-Security:
|
||||
- STS-XXX
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
X-Content-Type-Options:
|
||||
- X-CONTENT-TYPE-XXX
|
||||
access-control-expose-headers:
|
||||
- ACCESS-CONTROL-XXX
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
cf-cache-status:
|
||||
- DYNAMIC
|
||||
openai-organization:
|
||||
- OPENAI-ORG-XXX
|
||||
openai-processing-ms:
|
||||
- '14853'
|
||||
openai-project:
|
||||
- OPENAI-PROJECT-XXX
|
||||
openai-version:
|
||||
- '2020-10-01'
|
||||
set-cookie:
|
||||
- SET-COOKIE-XXX
|
||||
x-openai-proxy-wasm:
|
||||
- v0.1
|
||||
x-ratelimit-limit-requests:
|
||||
- X-RATELIMIT-LIMIT-REQUESTS-XXX
|
||||
x-ratelimit-limit-tokens:
|
||||
- X-RATELIMIT-LIMIT-TOKENS-XXX
|
||||
x-ratelimit-remaining-requests:
|
||||
- X-RATELIMIT-REMAINING-REQUESTS-XXX
|
||||
x-ratelimit-remaining-tokens:
|
||||
- X-RATELIMIT-REMAINING-TOKENS-XXX
|
||||
x-ratelimit-reset-requests:
|
||||
- X-RATELIMIT-RESET-REQUESTS-XXX
|
||||
x-ratelimit-reset-tokens:
|
||||
- X-RATELIMIT-RESET-TOKENS-XXX
|
||||
x-request-id:
|
||||
- X-REQUEST-ID-XXX
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: '{"messages":[{"role":"system","content":"You are Parallel Tool Agent. You
|
||||
follow tool instructions precisely.\nYour personal goal is: Use both tools exactly
|
||||
as instructed"},{"role":"user","content":"\nCurrent Task: This is a tool-calling
|
||||
compliance test. In your next assistant turn, emit exactly 3 tool calls in the
|
||||
same response (parallel tool calls), in this order: 1) parallel_local_search_one(query=''latest
|
||||
OpenAI model release notes''), 2) parallel_local_search_two(query=''latest Anthropic
|
||||
model release notes''), 3) parallel_local_search_three(query=''latest Gemini
|
||||
model release notes''). Do not call any other tools and do not answer before
|
||||
those 3 tool calls are emitted. After the tool results return, provide a one
|
||||
paragraph summary.\n\nThis is the expected criteria for your final answer: A
|
||||
one sentence summary of both tool outputs\nyou MUST return the actual complete
|
||||
content as the final answer, not a summary."},{"role":"assistant","content":null,"tool_calls":[{"id":"call_Putc2jV5GhiIZMwx8mDcI61Q","type":"function","function":{"name":"parallel_local_search_one","arguments":"{\"query\":
|
||||
\"latest OpenAI model release notes\"}"}},{"id":"call_iyjwcvkL3PdoOddxsqkHCT9T","type":"function","function":{"name":"parallel_local_search_two","arguments":"{\"query\":
|
||||
\"latest Anthropic model release notes\"}"}},{"id":"call_G728RseEU7SbGk5YTiyyp9IH","type":"function","function":{"name":"parallel_local_search_three","arguments":"{\"query\":
|
||||
\"latest Gemini model release notes\"}"}}]},{"role":"tool","tool_call_id":"call_Putc2jV5GhiIZMwx8mDcI61Q","name":"parallel_local_search_one","content":"[one]
|
||||
latest OpenAI model release notes"},{"role":"tool","tool_call_id":"call_iyjwcvkL3PdoOddxsqkHCT9T","name":"parallel_local_search_two","content":"[two]
|
||||
latest Anthropic model release notes"},{"role":"tool","tool_call_id":"call_G728RseEU7SbGk5YTiyyp9IH","name":"parallel_local_search_three","content":"[three]
|
||||
latest Gemini model release notes"},{"role":"user","content":"Analyze the tool
|
||||
result. If requirements are met, provide the Final Answer. Otherwise, call the
|
||||
next tool. Deliver only the answer without meta-commentary."}],"model":"gpt-5-nano","temperature":1,"tool_choice":"auto","tools":[{"type":"function","function":{"name":"parallel_local_search_one","description":"Local
|
||||
search tool #1 for concurrency testing.","strict":true,"parameters":{"properties":{"query":{"description":"Search
|
||||
query","title":"Query","type":"string"}},"required":["query"],"type":"object","additionalProperties":false}}},{"type":"function","function":{"name":"parallel_local_search_two","description":"Local
|
||||
search tool #2 for concurrency testing.","strict":true,"parameters":{"properties":{"query":{"description":"Search
|
||||
query","title":"Query","type":"string"}},"required":["query"],"type":"object","additionalProperties":false}}},{"type":"function","function":{"name":"parallel_local_search_three","description":"Local
|
||||
search tool #3 for concurrency testing.","strict":true,"parameters":{"properties":{"query":{"description":"Search
|
||||
query","title":"Query","type":"string"}},"required":["query"],"type":"object","additionalProperties":false}}}]}'
|
||||
headers:
|
||||
User-Agent:
|
||||
- X-USER-AGENT-XXX
|
||||
accept:
|
||||
- application/json
|
||||
accept-encoding:
|
||||
- ACCEPT-ENCODING-XXX
|
||||
authorization:
|
||||
- AUTHORIZATION-XXX
|
||||
connection:
|
||||
- keep-alive
|
||||
content-length:
|
||||
- '3136'
|
||||
content-type:
|
||||
- application/json
|
||||
cookie:
|
||||
- COOKIE-XXX
|
||||
host:
|
||||
- api.openai.com
|
||||
x-stainless-arch:
|
||||
- X-STAINLESS-ARCH-XXX
|
||||
x-stainless-async:
|
||||
- 'false'
|
||||
x-stainless-lang:
|
||||
- python
|
||||
x-stainless-os:
|
||||
- X-STAINLESS-OS-XXX
|
||||
x-stainless-package-version:
|
||||
- 1.83.0
|
||||
x-stainless-read-timeout:
|
||||
- X-STAINLESS-READ-TIMEOUT-XXX
|
||||
x-stainless-retry-count:
|
||||
- '0'
|
||||
x-stainless-runtime:
|
||||
- CPython
|
||||
x-stainless-runtime-version:
|
||||
- 3.13.3
|
||||
method: POST
|
||||
uri: https://api.openai.com/v1/chat/completions
|
||||
response:
|
||||
body:
|
||||
string: "{\n \"id\": \"chatcmpl-DAldt2BXNqiYYLPgInjHCpYKfk2VK\",\n \"object\":
|
||||
\"chat.completion\",\n \"created\": 1771458789,\n \"model\": \"gpt-5-nano-2025-08-07\",\n
|
||||
\ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\":
|
||||
\"assistant\",\n \"content\": \"The results show the latest model release
|
||||
notes for OpenAI, Anthropic, and Gemini.\",\n \"refusal\": null,\n
|
||||
\ \"annotations\": []\n },\n \"finish_reason\": \"stop\"\n
|
||||
\ }\n ],\n \"usage\": {\n \"prompt_tokens\": 537,\n \"completion_tokens\":
|
||||
2011,\n \"total_tokens\": 2548,\n \"prompt_tokens_details\": {\n \"cached_tokens\":
|
||||
0,\n \"audio_tokens\": 0\n },\n \"completion_tokens_details\":
|
||||
{\n \"reasoning_tokens\": 1984,\n \"audio_tokens\": 0,\n \"accepted_prediction_tokens\":
|
||||
0,\n \"rejected_prediction_tokens\": 0\n }\n },\n \"service_tier\":
|
||||
\"default\",\n \"system_fingerprint\": null\n}\n"
|
||||
headers:
|
||||
CF-RAY:
|
||||
- CF-RAY-XXX
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Wed, 18 Feb 2026 23:53:25 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Strict-Transport-Security:
|
||||
- STS-XXX
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
X-Content-Type-Options:
|
||||
- X-CONTENT-TYPE-XXX
|
||||
access-control-expose-headers:
|
||||
- ACCESS-CONTROL-XXX
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
cf-cache-status:
|
||||
- DYNAMIC
|
||||
openai-organization:
|
||||
- OPENAI-ORG-XXX
|
||||
openai-processing-ms:
|
||||
- '15368'
|
||||
openai-project:
|
||||
- OPENAI-PROJECT-XXX
|
||||
openai-version:
|
||||
- '2020-10-01'
|
||||
x-openai-proxy-wasm:
|
||||
- v0.1
|
||||
x-ratelimit-limit-requests:
|
||||
- X-RATELIMIT-LIMIT-REQUESTS-XXX
|
||||
x-ratelimit-limit-tokens:
|
||||
- X-RATELIMIT-LIMIT-TOKENS-XXX
|
||||
x-ratelimit-remaining-requests:
|
||||
- X-RATELIMIT-REMAINING-REQUESTS-XXX
|
||||
x-ratelimit-remaining-tokens:
|
||||
- X-RATELIMIT-REMAINING-TOKENS-XXX
|
||||
x-ratelimit-reset-requests:
|
||||
- X-RATELIMIT-RESET-REQUESTS-XXX
|
||||
x-ratelimit-reset-tokens:
|
||||
- X-RATELIMIT-RESET-TOKENS-XXX
|
||||
x-request-id:
|
||||
- X-REQUEST-ID-XXX
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
version: 1
|
||||
@@ -0,0 +1,264 @@
|
||||
interactions:
|
||||
- request:
|
||||
body: '{"messages":[{"role":"system","content":"You are Parallel Tool Agent. You
|
||||
follow tool instructions precisely.\nYour personal goal is: Use both tools exactly
|
||||
as instructed"},{"role":"user","content":"\nCurrent Task: This is a tool-calling
|
||||
compliance test. In your next assistant turn, emit exactly 3 tool calls in the
|
||||
same response (parallel tool calls), in this order: 1) parallel_local_search_one(query=''latest
|
||||
OpenAI model release notes''), 2) parallel_local_search_two(query=''latest Anthropic
|
||||
model release notes''), 3) parallel_local_search_three(query=''latest Gemini
|
||||
model release notes''). Do not call any other tools and do not answer before
|
||||
those 3 tool calls are emitted. After the tool results return, provide a one
|
||||
paragraph summary."}],"model":"gpt-5-nano","temperature":1,"tool_choice":"auto","tools":[{"type":"function","function":{"name":"parallel_local_search_one","description":"Local
|
||||
search tool #1 for concurrency testing.","strict":true,"parameters":{"properties":{"query":{"description":"Search
|
||||
query","title":"Query","type":"string"}},"required":["query"],"type":"object","additionalProperties":false}}},{"type":"function","function":{"name":"parallel_local_search_two","description":"Local
|
||||
search tool #2 for concurrency testing.","strict":true,"parameters":{"properties":{"query":{"description":"Search
|
||||
query","title":"Query","type":"string"}},"required":["query"],"type":"object","additionalProperties":false}}},{"type":"function","function":{"name":"parallel_local_search_three","description":"Local
|
||||
search tool #3 for concurrency testing.","strict":true,"parameters":{"properties":{"query":{"description":"Search
|
||||
query","title":"Query","type":"string"}},"required":["query"],"type":"object","additionalProperties":false}}}]}'
|
||||
headers:
|
||||
User-Agent:
|
||||
- X-USER-AGENT-XXX
|
||||
accept:
|
||||
- application/json
|
||||
accept-encoding:
|
||||
- ACCEPT-ENCODING-XXX
|
||||
authorization:
|
||||
- AUTHORIZATION-XXX
|
||||
connection:
|
||||
- keep-alive
|
||||
content-length:
|
||||
- '1748'
|
||||
content-type:
|
||||
- application/json
|
||||
host:
|
||||
- api.openai.com
|
||||
x-stainless-arch:
|
||||
- X-STAINLESS-ARCH-XXX
|
||||
x-stainless-async:
|
||||
- 'false'
|
||||
x-stainless-lang:
|
||||
- python
|
||||
x-stainless-os:
|
||||
- X-STAINLESS-OS-XXX
|
||||
x-stainless-package-version:
|
||||
- 1.83.0
|
||||
x-stainless-read-timeout:
|
||||
- X-STAINLESS-READ-TIMEOUT-XXX
|
||||
x-stainless-retry-count:
|
||||
- '0'
|
||||
x-stainless-runtime:
|
||||
- CPython
|
||||
x-stainless-runtime-version:
|
||||
- 3.13.3
|
||||
method: POST
|
||||
uri: https://api.openai.com/v1/chat/completions
|
||||
response:
|
||||
body:
|
||||
string: "{\n \"id\": \"chatcmpl-DB244zBgA66fzl8TNcIPRWoE4lDIQ\",\n \"object\":
|
||||
\"chat.completion\",\n \"created\": 1771521916,\n \"model\": \"gpt-5-nano-2025-08-07\",\n
|
||||
\ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\":
|
||||
\"assistant\",\n \"content\": null,\n \"tool_calls\": [\n {\n
|
||||
\ \"id\": \"call_D2ojRWqkng6krQ51vWQEU8wR\",\n \"type\":
|
||||
\"function\",\n \"function\": {\n \"name\": \"parallel_local_search_one\",\n
|
||||
\ \"arguments\": \"{\\\"query\\\": \\\"latest OpenAI model release
|
||||
notes\\\"}\"\n }\n },\n {\n \"id\":
|
||||
\"call_v1tpTKw1sYcI75SWG1LCkAC3\",\n \"type\": \"function\",\n
|
||||
\ \"function\": {\n \"name\": \"parallel_local_search_two\",\n
|
||||
\ \"arguments\": \"{\\\"query\\\": \\\"latest Anthropic model
|
||||
release notes\\\"}\"\n }\n },\n {\n \"id\":
|
||||
\"call_RrbyZClymnngoNLhlkQLLpwM\",\n \"type\": \"function\",\n
|
||||
\ \"function\": {\n \"name\": \"parallel_local_search_three\",\n
|
||||
\ \"arguments\": \"{\\\"query\\\": \\\"latest Gemini model release
|
||||
notes\\\"}\"\n }\n }\n ],\n \"refusal\":
|
||||
null,\n \"annotations\": []\n },\n \"finish_reason\": \"tool_calls\"\n
|
||||
\ }\n ],\n \"usage\": {\n \"prompt_tokens\": 343,\n \"completion_tokens\":
|
||||
855,\n \"total_tokens\": 1198,\n \"prompt_tokens_details\": {\n \"cached_tokens\":
|
||||
0,\n \"audio_tokens\": 0\n },\n \"completion_tokens_details\":
|
||||
{\n \"reasoning_tokens\": 768,\n \"audio_tokens\": 0,\n \"accepted_prediction_tokens\":
|
||||
0,\n \"rejected_prediction_tokens\": 0\n }\n },\n \"service_tier\":
|
||||
\"default\",\n \"system_fingerprint\": null\n}\n"
|
||||
headers:
|
||||
CF-RAY:
|
||||
- CF-RAY-XXX
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Thu, 19 Feb 2026 17:25:23 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Strict-Transport-Security:
|
||||
- STS-XXX
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
X-Content-Type-Options:
|
||||
- X-CONTENT-TYPE-XXX
|
||||
access-control-expose-headers:
|
||||
- ACCESS-CONTROL-XXX
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
cf-cache-status:
|
||||
- DYNAMIC
|
||||
openai-organization:
|
||||
- OPENAI-ORG-XXX
|
||||
openai-processing-ms:
|
||||
- '6669'
|
||||
openai-project:
|
||||
- OPENAI-PROJECT-XXX
|
||||
openai-version:
|
||||
- '2020-10-01'
|
||||
set-cookie:
|
||||
- SET-COOKIE-XXX
|
||||
x-openai-proxy-wasm:
|
||||
- v0.1
|
||||
x-ratelimit-limit-requests:
|
||||
- X-RATELIMIT-LIMIT-REQUESTS-XXX
|
||||
x-ratelimit-limit-tokens:
|
||||
- X-RATELIMIT-LIMIT-TOKENS-XXX
|
||||
x-ratelimit-remaining-requests:
|
||||
- X-RATELIMIT-REMAINING-REQUESTS-XXX
|
||||
x-ratelimit-remaining-tokens:
|
||||
- X-RATELIMIT-REMAINING-TOKENS-XXX
|
||||
x-ratelimit-reset-requests:
|
||||
- X-RATELIMIT-RESET-REQUESTS-XXX
|
||||
x-ratelimit-reset-tokens:
|
||||
- X-RATELIMIT-RESET-TOKENS-XXX
|
||||
x-request-id:
|
||||
- X-REQUEST-ID-XXX
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: '{"messages":[{"role":"system","content":"You are Parallel Tool Agent. You
|
||||
follow tool instructions precisely.\nYour personal goal is: Use both tools exactly
|
||||
as instructed"},{"role":"user","content":"\nCurrent Task: This is a tool-calling
|
||||
compliance test. In your next assistant turn, emit exactly 3 tool calls in the
|
||||
same response (parallel tool calls), in this order: 1) parallel_local_search_one(query=''latest
|
||||
OpenAI model release notes''), 2) parallel_local_search_two(query=''latest Anthropic
|
||||
model release notes''), 3) parallel_local_search_three(query=''latest Gemini
|
||||
model release notes''). Do not call any other tools and do not answer before
|
||||
those 3 tool calls are emitted. After the tool results return, provide a one
|
||||
paragraph summary."},{"role":"assistant","content":null,"tool_calls":[{"id":"call_D2ojRWqkng6krQ51vWQEU8wR","type":"function","function":{"name":"parallel_local_search_one","arguments":"{\"query\":
|
||||
\"latest OpenAI model release notes\"}"}},{"id":"call_v1tpTKw1sYcI75SWG1LCkAC3","type":"function","function":{"name":"parallel_local_search_two","arguments":"{\"query\":
|
||||
\"latest Anthropic model release notes\"}"}},{"id":"call_RrbyZClymnngoNLhlkQLLpwM","type":"function","function":{"name":"parallel_local_search_three","arguments":"{\"query\":
|
||||
\"latest Gemini model release notes\"}"}}]},{"role":"tool","tool_call_id":"call_D2ojRWqkng6krQ51vWQEU8wR","name":"parallel_local_search_one","content":"[one]
|
||||
latest OpenAI model release notes"},{"role":"tool","tool_call_id":"call_v1tpTKw1sYcI75SWG1LCkAC3","name":"parallel_local_search_two","content":"[two]
|
||||
latest Anthropic model release notes"},{"role":"tool","tool_call_id":"call_RrbyZClymnngoNLhlkQLLpwM","name":"parallel_local_search_three","content":"[three]
|
||||
latest Gemini model release notes"}],"model":"gpt-5-nano","temperature":1,"tool_choice":"auto","tools":[{"type":"function","function":{"name":"parallel_local_search_one","description":"Local
|
||||
search tool #1 for concurrency testing.","strict":true,"parameters":{"properties":{"query":{"description":"Search
|
||||
query","title":"Query","type":"string"}},"required":["query"],"type":"object","additionalProperties":false}}},{"type":"function","function":{"name":"parallel_local_search_two","description":"Local
|
||||
search tool #2 for concurrency testing.","strict":true,"parameters":{"properties":{"query":{"description":"Search
|
||||
query","title":"Query","type":"string"}},"required":["query"],"type":"object","additionalProperties":false}}},{"type":"function","function":{"name":"parallel_local_search_three","description":"Local
|
||||
search tool #3 for concurrency testing.","strict":true,"parameters":{"properties":{"query":{"description":"Search
|
||||
query","title":"Query","type":"string"}},"required":["query"],"type":"object","additionalProperties":false}}}]}'
|
||||
headers:
|
||||
User-Agent:
|
||||
- X-USER-AGENT-XXX
|
||||
accept:
|
||||
- application/json
|
||||
accept-encoding:
|
||||
- ACCEPT-ENCODING-XXX
|
||||
authorization:
|
||||
- AUTHORIZATION-XXX
|
||||
connection:
|
||||
- keep-alive
|
||||
content-length:
|
||||
- '2771'
|
||||
content-type:
|
||||
- application/json
|
||||
cookie:
|
||||
- COOKIE-XXX
|
||||
host:
|
||||
- api.openai.com
|
||||
x-stainless-arch:
|
||||
- X-STAINLESS-ARCH-XXX
|
||||
x-stainless-async:
|
||||
- 'false'
|
||||
x-stainless-lang:
|
||||
- python
|
||||
x-stainless-os:
|
||||
- X-STAINLESS-OS-XXX
|
||||
x-stainless-package-version:
|
||||
- 1.83.0
|
||||
x-stainless-read-timeout:
|
||||
- X-STAINLESS-READ-TIMEOUT-XXX
|
||||
x-stainless-retry-count:
|
||||
- '0'
|
||||
x-stainless-runtime:
|
||||
- CPython
|
||||
x-stainless-runtime-version:
|
||||
- 3.13.3
|
||||
method: POST
|
||||
uri: https://api.openai.com/v1/chat/completions
|
||||
response:
|
||||
body:
|
||||
string: "{\n \"id\": \"chatcmpl-DB24DjyYsIHiQJ7hHXob8tQFfeXBs\",\n \"object\":
|
||||
\"chat.completion\",\n \"created\": 1771521925,\n \"model\": \"gpt-5-nano-2025-08-07\",\n
|
||||
\ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\":
|
||||
\"assistant\",\n \"content\": \"The three latest release-note references
|
||||
retrieved encompass OpenAI, Anthropic, and Gemini, indicating that all three
|
||||
major model families are actively updating their offerings. These notes typically
|
||||
cover improvements to capabilities, safety measures, performance enhancements,
|
||||
and any new APIs or features, suggesting a trend of ongoing refinement across
|
||||
providers. If you\u2019d like, I can pull the full release notes or extract
|
||||
and compare the key changes across the three sources.\",\n \"refusal\":
|
||||
null,\n \"annotations\": []\n },\n \"finish_reason\": \"stop\"\n
|
||||
\ }\n ],\n \"usage\": {\n \"prompt_tokens\": 467,\n \"completion_tokens\":
|
||||
1437,\n \"total_tokens\": 1904,\n \"prompt_tokens_details\": {\n \"cached_tokens\":
|
||||
0,\n \"audio_tokens\": 0\n },\n \"completion_tokens_details\":
|
||||
{\n \"reasoning_tokens\": 1344,\n \"audio_tokens\": 0,\n \"accepted_prediction_tokens\":
|
||||
0,\n \"rejected_prediction_tokens\": 0\n }\n },\n \"service_tier\":
|
||||
\"default\",\n \"system_fingerprint\": null\n}\n"
|
||||
headers:
|
||||
CF-RAY:
|
||||
- CF-RAY-XXX
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Thu, 19 Feb 2026 17:25:35 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Strict-Transport-Security:
|
||||
- STS-XXX
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
X-Content-Type-Options:
|
||||
- X-CONTENT-TYPE-XXX
|
||||
access-control-expose-headers:
|
||||
- ACCESS-CONTROL-XXX
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
cf-cache-status:
|
||||
- DYNAMIC
|
||||
openai-organization:
|
||||
- OPENAI-ORG-XXX
|
||||
openai-processing-ms:
|
||||
- '10369'
|
||||
openai-project:
|
||||
- OPENAI-PROJECT-XXX
|
||||
openai-version:
|
||||
- '2020-10-01'
|
||||
x-openai-proxy-wasm:
|
||||
- v0.1
|
||||
x-ratelimit-limit-requests:
|
||||
- X-RATELIMIT-LIMIT-REQUESTS-XXX
|
||||
x-ratelimit-limit-tokens:
|
||||
- X-RATELIMIT-LIMIT-TOKENS-XXX
|
||||
x-ratelimit-remaining-requests:
|
||||
- X-RATELIMIT-REMAINING-REQUESTS-XXX
|
||||
x-ratelimit-remaining-tokens:
|
||||
- X-RATELIMIT-REMAINING-TOKENS-XXX
|
||||
x-ratelimit-reset-requests:
|
||||
- X-RATELIMIT-RESET-REQUESTS-XXX
|
||||
x-ratelimit-reset-tokens:
|
||||
- X-RATELIMIT-RESET-TOKENS-XXX
|
||||
x-request-id:
|
||||
- X-REQUEST-ID-XXX
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
version: 1
|
||||
@@ -0,0 +1,339 @@
|
||||
interactions:
|
||||
- request:
|
||||
body: '{"trace_id": "e456cc10-ce7b-4e68-a2cc-ddb806a2e7b9", "execution_type":
|
||||
"crew", "user_identifier": null, "execution_context": {"crew_fingerprint": null,
|
||||
"crew_name": "crew", "flow_name": null, "crewai_version": "1.9.3", "privacy_level":
|
||||
"standard"}, "execution_metadata": {"expected_duration_estimate": 300, "agent_count":
|
||||
0, "task_count": 0, "flow_method_count": 0, "execution_started_at": "2026-02-19T17:24:41.723158+00:00"},
|
||||
"ephemeral_trace_id": "e456cc10-ce7b-4e68-a2cc-ddb806a2e7b9"}'
|
||||
headers:
|
||||
Accept:
|
||||
- '*/*'
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '488'
|
||||
Content-Type:
|
||||
- application/json
|
||||
User-Agent:
|
||||
- X-USER-AGENT-XXX
|
||||
X-Crewai-Organization-Id:
|
||||
- 3433f0ee-8a94-4aa4-822b-2ac71aa38b18
|
||||
X-Crewai-Version:
|
||||
- 1.9.3
|
||||
accept-encoding:
|
||||
- ACCEPT-ENCODING-XXX
|
||||
authorization:
|
||||
- AUTHORIZATION-XXX
|
||||
method: POST
|
||||
uri: https://app.crewai.com/crewai_plus/api/v1/tracing/ephemeral/batches
|
||||
response:
|
||||
body:
|
||||
string: '{"id":"a78f2aca-0525-47c7-8f37-b3fca0ad6672","ephemeral_trace_id":"e456cc10-ce7b-4e68-a2cc-ddb806a2e7b9","execution_type":"crew","crew_name":"crew","flow_name":null,"status":"running","duration_ms":null,"crewai_version":"1.9.3","total_events":0,"execution_context":{"crew_fingerprint":null,"crew_name":"crew","flow_name":null,"crewai_version":"1.9.3","privacy_level":"standard"},"created_at":"2026-02-19T17:24:41.989Z","updated_at":"2026-02-19T17:24:41.989Z","access_code":"TRACE-bd80d6be74","user_identifier":null}'
|
||||
headers:
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '515'
|
||||
Content-Type:
|
||||
- application/json; charset=utf-8
|
||||
Date:
|
||||
- Thu, 19 Feb 2026 17:24:41 GMT
|
||||
cache-control:
|
||||
- no-store
|
||||
content-security-policy:
|
||||
- CSP-FILTERED
|
||||
etag:
|
||||
- ETAG-XXX
|
||||
expires:
|
||||
- '0'
|
||||
permissions-policy:
|
||||
- PERMISSIONS-POLICY-XXX
|
||||
pragma:
|
||||
- no-cache
|
||||
referrer-policy:
|
||||
- REFERRER-POLICY-XXX
|
||||
strict-transport-security:
|
||||
- STS-XXX
|
||||
vary:
|
||||
- Accept
|
||||
x-content-type-options:
|
||||
- X-CONTENT-TYPE-XXX
|
||||
x-frame-options:
|
||||
- X-FRAME-OPTIONS-XXX
|
||||
x-permitted-cross-domain-policies:
|
||||
- X-PERMITTED-XXX
|
||||
x-request-id:
|
||||
- X-REQUEST-ID-XXX
|
||||
x-runtime:
|
||||
- X-RUNTIME-XXX
|
||||
x-xss-protection:
|
||||
- X-XSS-PROTECTION-XXX
|
||||
status:
|
||||
code: 201
|
||||
message: Created
|
||||
- request:
|
||||
body: '{"messages":[{"role":"system","content":"You are Parallel Tool Agent. You
|
||||
follow tool instructions precisely.\nYour personal goal is: Use both tools exactly
|
||||
as instructed"},{"role":"user","content":"\nCurrent Task: This is a tool-calling
|
||||
compliance test. In your next assistant turn, emit exactly 3 tool calls in the
|
||||
same response (parallel tool calls), in this order: 1) parallel_local_search_one(query=''latest
|
||||
OpenAI model release notes''), 2) parallel_local_search_two(query=''latest Anthropic
|
||||
model release notes''), 3) parallel_local_search_three(query=''latest Gemini
|
||||
model release notes''). Do not call any other tools and do not answer before
|
||||
those 3 tool calls are emitted. After the tool results return, provide a one
|
||||
paragraph summary.\n\nThis is the expected criteria for your final answer: A
|
||||
one sentence summary of both tool outputs\nyou MUST return the actual complete
|
||||
content as the final answer, not a summary."}],"model":"gpt-5-nano","temperature":1,"tool_choice":"auto","tools":[{"type":"function","function":{"name":"parallel_local_search_one","description":"Local
|
||||
search tool #1 for concurrency testing.","strict":true,"parameters":{"properties":{"query":{"description":"Search
|
||||
query","title":"Query","type":"string"}},"required":["query"],"type":"object","additionalProperties":false}}},{"type":"function","function":{"name":"parallel_local_search_two","description":"Local
|
||||
search tool #2 for concurrency testing.","strict":true,"parameters":{"properties":{"query":{"description":"Search
|
||||
query","title":"Query","type":"string"}},"required":["query"],"type":"object","additionalProperties":false}}},{"type":"function","function":{"name":"parallel_local_search_three","description":"Local
|
||||
search tool #3 for concurrency testing.","strict":true,"parameters":{"properties":{"query":{"description":"Search
|
||||
query","title":"Query","type":"string"}},"required":["query"],"type":"object","additionalProperties":false}}}]}'
|
||||
headers:
|
||||
User-Agent:
|
||||
- X-USER-AGENT-XXX
|
||||
accept:
|
||||
- application/json
|
||||
accept-encoding:
|
||||
- ACCEPT-ENCODING-XXX
|
||||
authorization:
|
||||
- AUTHORIZATION-XXX
|
||||
connection:
|
||||
- keep-alive
|
||||
content-length:
|
||||
- '1929'
|
||||
content-type:
|
||||
- application/json
|
||||
host:
|
||||
- api.openai.com
|
||||
x-stainless-arch:
|
||||
- X-STAINLESS-ARCH-XXX
|
||||
x-stainless-async:
|
||||
- 'false'
|
||||
x-stainless-lang:
|
||||
- python
|
||||
x-stainless-os:
|
||||
- X-STAINLESS-OS-XXX
|
||||
x-stainless-package-version:
|
||||
- 1.83.0
|
||||
x-stainless-read-timeout:
|
||||
- X-STAINLESS-READ-TIMEOUT-XXX
|
||||
x-stainless-retry-count:
|
||||
- '0'
|
||||
x-stainless-runtime:
|
||||
- CPython
|
||||
x-stainless-runtime-version:
|
||||
- 3.13.3
|
||||
method: POST
|
||||
uri: https://api.openai.com/v1/chat/completions
|
||||
response:
|
||||
body:
|
||||
string: "{\n \"id\": \"chatcmpl-DB23W8RBF6zlxweiHYGb6maVfyctt\",\n \"object\":
|
||||
\"chat.completion\",\n \"created\": 1771521882,\n \"model\": \"gpt-5-nano-2025-08-07\",\n
|
||||
\ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\":
|
||||
\"assistant\",\n \"content\": null,\n \"tool_calls\": [\n {\n
|
||||
\ \"id\": \"call_sge1FXUkpmPEDe8nTOgn0tQG\",\n \"type\":
|
||||
\"function\",\n \"function\": {\n \"name\": \"parallel_local_search_one\",\n
|
||||
\ \"arguments\": \"{\\\"query\\\": \\\"latest OpenAI model release
|
||||
notes\\\"}\"\n }\n },\n {\n \"id\":
|
||||
\"call_z5jRPH4DQ7Wp3HdDUlZe8gGh\",\n \"type\": \"function\",\n
|
||||
\ \"function\": {\n \"name\": \"parallel_local_search_two\",\n
|
||||
\ \"arguments\": \"{\\\"query\\\": \\\"latest Anthropic model
|
||||
release notes\\\"}\"\n }\n },\n {\n \"id\":
|
||||
\"call_DNlgqnadODDsyQkSuLcXZCX2\",\n \"type\": \"function\",\n
|
||||
\ \"function\": {\n \"name\": \"parallel_local_search_three\",\n
|
||||
\ \"arguments\": \"{\\\"query\\\": \\\"latest Gemini model release
|
||||
notes\\\"}\"\n }\n }\n ],\n \"refusal\":
|
||||
null,\n \"annotations\": []\n },\n \"finish_reason\": \"tool_calls\"\n
|
||||
\ }\n ],\n \"usage\": {\n \"prompt_tokens\": 378,\n \"completion_tokens\":
|
||||
2456,\n \"total_tokens\": 2834,\n \"prompt_tokens_details\": {\n \"cached_tokens\":
|
||||
0,\n \"audio_tokens\": 0\n },\n \"completion_tokens_details\":
|
||||
{\n \"reasoning_tokens\": 2368,\n \"audio_tokens\": 0,\n \"accepted_prediction_tokens\":
|
||||
0,\n \"rejected_prediction_tokens\": 0\n }\n },\n \"service_tier\":
|
||||
\"default\",\n \"system_fingerprint\": null\n}\n"
|
||||
headers:
|
||||
CF-RAY:
|
||||
- CF-RAY-XXX
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Thu, 19 Feb 2026 17:25:02 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Strict-Transport-Security:
|
||||
- STS-XXX
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
X-Content-Type-Options:
|
||||
- X-CONTENT-TYPE-XXX
|
||||
access-control-expose-headers:
|
||||
- ACCESS-CONTROL-XXX
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
cf-cache-status:
|
||||
- DYNAMIC
|
||||
openai-organization:
|
||||
- OPENAI-ORG-XXX
|
||||
openai-processing-ms:
|
||||
- '19582'
|
||||
openai-project:
|
||||
- OPENAI-PROJECT-XXX
|
||||
openai-version:
|
||||
- '2020-10-01'
|
||||
set-cookie:
|
||||
- SET-COOKIE-XXX
|
||||
x-openai-proxy-wasm:
|
||||
- v0.1
|
||||
x-ratelimit-limit-requests:
|
||||
- X-RATELIMIT-LIMIT-REQUESTS-XXX
|
||||
x-ratelimit-limit-tokens:
|
||||
- X-RATELIMIT-LIMIT-TOKENS-XXX
|
||||
x-ratelimit-remaining-requests:
|
||||
- X-RATELIMIT-REMAINING-REQUESTS-XXX
|
||||
x-ratelimit-remaining-tokens:
|
||||
- X-RATELIMIT-REMAINING-TOKENS-XXX
|
||||
x-ratelimit-reset-requests:
|
||||
- X-RATELIMIT-RESET-REQUESTS-XXX
|
||||
x-ratelimit-reset-tokens:
|
||||
- X-RATELIMIT-RESET-TOKENS-XXX
|
||||
x-request-id:
|
||||
- X-REQUEST-ID-XXX
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: '{"messages":[{"role":"system","content":"You are Parallel Tool Agent. You
|
||||
follow tool instructions precisely.\nYour personal goal is: Use both tools exactly
|
||||
as instructed"},{"role":"user","content":"\nCurrent Task: This is a tool-calling
|
||||
compliance test. In your next assistant turn, emit exactly 3 tool calls in the
|
||||
same response (parallel tool calls), in this order: 1) parallel_local_search_one(query=''latest
|
||||
OpenAI model release notes''), 2) parallel_local_search_two(query=''latest Anthropic
|
||||
model release notes''), 3) parallel_local_search_three(query=''latest Gemini
|
||||
model release notes''). Do not call any other tools and do not answer before
|
||||
those 3 tool calls are emitted. After the tool results return, provide a one
|
||||
paragraph summary.\n\nThis is the expected criteria for your final answer: A
|
||||
one sentence summary of both tool outputs\nyou MUST return the actual complete
|
||||
content as the final answer, not a summary."},{"role":"assistant","content":null,"tool_calls":[{"id":"call_sge1FXUkpmPEDe8nTOgn0tQG","type":"function","function":{"name":"parallel_local_search_one","arguments":"{\"query\":
|
||||
\"latest OpenAI model release notes\"}"}},{"id":"call_z5jRPH4DQ7Wp3HdDUlZe8gGh","type":"function","function":{"name":"parallel_local_search_two","arguments":"{\"query\":
|
||||
\"latest Anthropic model release notes\"}"}},{"id":"call_DNlgqnadODDsyQkSuLcXZCX2","type":"function","function":{"name":"parallel_local_search_three","arguments":"{\"query\":
|
||||
\"latest Gemini model release notes\"}"}}]},{"role":"tool","tool_call_id":"call_sge1FXUkpmPEDe8nTOgn0tQG","name":"parallel_local_search_one","content":"[one]
|
||||
latest OpenAI model release notes"},{"role":"tool","tool_call_id":"call_z5jRPH4DQ7Wp3HdDUlZe8gGh","name":"parallel_local_search_two","content":"[two]
|
||||
latest Anthropic model release notes"},{"role":"tool","tool_call_id":"call_DNlgqnadODDsyQkSuLcXZCX2","name":"parallel_local_search_three","content":"[three]
|
||||
latest Gemini model release notes"},{"role":"user","content":"Analyze the tool
|
||||
result. If requirements are met, provide the Final Answer. Otherwise, call the
|
||||
next tool. Deliver only the answer without meta-commentary."}],"model":"gpt-5-nano","temperature":1,"tool_choice":"auto","tools":[{"type":"function","function":{"name":"parallel_local_search_one","description":"Local
|
||||
search tool #1 for concurrency testing.","strict":true,"parameters":{"properties":{"query":{"description":"Search
|
||||
query","title":"Query","type":"string"}},"required":["query"],"type":"object","additionalProperties":false}}},{"type":"function","function":{"name":"parallel_local_search_two","description":"Local
|
||||
search tool #2 for concurrency testing.","strict":true,"parameters":{"properties":{"query":{"description":"Search
|
||||
query","title":"Query","type":"string"}},"required":["query"],"type":"object","additionalProperties":false}}},{"type":"function","function":{"name":"parallel_local_search_three","description":"Local
|
||||
search tool #3 for concurrency testing.","strict":true,"parameters":{"properties":{"query":{"description":"Search
|
||||
query","title":"Query","type":"string"}},"required":["query"],"type":"object","additionalProperties":false}}}]}'
|
||||
headers:
|
||||
User-Agent:
|
||||
- X-USER-AGENT-XXX
|
||||
accept:
|
||||
- application/json
|
||||
accept-encoding:
|
||||
- ACCEPT-ENCODING-XXX
|
||||
authorization:
|
||||
- AUTHORIZATION-XXX
|
||||
connection:
|
||||
- keep-alive
|
||||
content-length:
|
||||
- '3136'
|
||||
content-type:
|
||||
- application/json
|
||||
cookie:
|
||||
- COOKIE-XXX
|
||||
host:
|
||||
- api.openai.com
|
||||
x-stainless-arch:
|
||||
- X-STAINLESS-ARCH-XXX
|
||||
x-stainless-async:
|
||||
- 'false'
|
||||
x-stainless-lang:
|
||||
- python
|
||||
x-stainless-os:
|
||||
- X-STAINLESS-OS-XXX
|
||||
x-stainless-package-version:
|
||||
- 1.83.0
|
||||
x-stainless-read-timeout:
|
||||
- X-STAINLESS-READ-TIMEOUT-XXX
|
||||
x-stainless-retry-count:
|
||||
- '0'
|
||||
x-stainless-runtime:
|
||||
- CPython
|
||||
x-stainless-runtime-version:
|
||||
- 3.13.3
|
||||
method: POST
|
||||
uri: https://api.openai.com/v1/chat/completions
|
||||
response:
|
||||
body:
|
||||
string: "{\n \"id\": \"chatcmpl-DB23sY0Ahpd1yAgLZ882KkA50Zljx\",\n \"object\":
|
||||
\"chat.completion\",\n \"created\": 1771521904,\n \"model\": \"gpt-5-nano-2025-08-07\",\n
|
||||
\ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\":
|
||||
\"assistant\",\n \"content\": \"Results returned three items: the latest
|
||||
OpenAI model release notes, the latest Anthropic model release notes, and
|
||||
the latest Gemini model release notes.\",\n \"refusal\": null,\n \"annotations\":
|
||||
[]\n },\n \"finish_reason\": \"stop\"\n }\n ],\n \"usage\":
|
||||
{\n \"prompt_tokens\": 537,\n \"completion_tokens\": 1383,\n \"total_tokens\":
|
||||
1920,\n \"prompt_tokens_details\": {\n \"cached_tokens\": 0,\n \"audio_tokens\":
|
||||
0\n },\n \"completion_tokens_details\": {\n \"reasoning_tokens\":
|
||||
1344,\n \"audio_tokens\": 0,\n \"accepted_prediction_tokens\": 0,\n
|
||||
\ \"rejected_prediction_tokens\": 0\n }\n },\n \"service_tier\":
|
||||
\"default\",\n \"system_fingerprint\": null\n}\n"
|
||||
headers:
|
||||
CF-RAY:
|
||||
- CF-RAY-XXX
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Thu, 19 Feb 2026 17:25:16 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Strict-Transport-Security:
|
||||
- STS-XXX
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
X-Content-Type-Options:
|
||||
- X-CONTENT-TYPE-XXX
|
||||
access-control-expose-headers:
|
||||
- ACCESS-CONTROL-XXX
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
cf-cache-status:
|
||||
- DYNAMIC
|
||||
openai-organization:
|
||||
- OPENAI-ORG-XXX
|
||||
openai-processing-ms:
|
||||
- '12339'
|
||||
openai-project:
|
||||
- OPENAI-PROJECT-XXX
|
||||
openai-version:
|
||||
- '2020-10-01'
|
||||
x-openai-proxy-wasm:
|
||||
- v0.1
|
||||
x-ratelimit-limit-requests:
|
||||
- X-RATELIMIT-LIMIT-REQUESTS-XXX
|
||||
x-ratelimit-limit-tokens:
|
||||
- X-RATELIMIT-LIMIT-TOKENS-XXX
|
||||
x-ratelimit-remaining-requests:
|
||||
- X-RATELIMIT-REMAINING-REQUESTS-XXX
|
||||
x-ratelimit-remaining-tokens:
|
||||
- X-RATELIMIT-REMAINING-TOKENS-XXX
|
||||
x-ratelimit-reset-requests:
|
||||
- X-RATELIMIT-RESET-REQUESTS-XXX
|
||||
x-ratelimit-reset-tokens:
|
||||
- X-RATELIMIT-RESET-TOKENS-XXX
|
||||
x-request-id:
|
||||
- X-REQUEST-ID-XXX
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
version: 1
|
||||
Reference in New Issue
Block a user