Commit Graph

113 Commits

Author SHA1 Message Date
Víctor Mayoral Vilches 47681c6853 Update docs including guardrails
Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>
2025-08-29 14:01:42 +00:00
Víctor Mayoral Vilches d1b42233e6
Prompt injection mitigation (#249)
* Reproduce prompt injection flaw in CAI

Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>

* Mitigate prompt injection

Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>

* Add a second PoC, refactor and propose a message when guardrails are triggered

Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>

* Add CAI_GUARDRAILS and 2 additional PoCs

Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>

* Mitigate PoC 3

Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>

* Mitigate PoC 4

Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>

* Add and mitigate PoCs 5 and 6

Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>

* Add PoCs 7 to 10

Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>

* Test and mitigate PoCs 7 to 10

Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>

* Add PoCs 11 to 14

Inspired by 'Embrade The Red' research and also by 'The Month of AI bugs'

Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>

* Mitigate PoCs 11 to 14

Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>

---------

Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>
2025-08-28 20:25:24 +02:00
Víctor Mayoral Vilches 13350afcee Contribute CAI Fluency first bits
Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>
2025-07-03 16:00:36 +02:00
Mery-Sanz fd1a4e9b50 add faq license 2025-06-18 08:28:34 +00:00
Víctor Mayoral Vilches bdecebd814 Revert "Apply code formatting with make format" 2025-06-14 09:51:19 +00:00
Víctor Mayoral Vilches d41f3e38d4 Update doc's index
Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>
2025-06-03 06:58:40 +00:00
Víctor Mayoral Vilches 85204ca344 Update CAI's docs with case studies
Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>
2025-06-03 06:58:27 +00:00
Víctor Mayoral Vilches 9c60bc0329 switch to .3 for 0.4.0 to avoid conflicts
Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>
2025-05-26 10:58:49 +02:00
Víctor Mayoral Vilches 6b5adbb3c1 Add some bits to docs
Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>
2025-05-14 14:44:23 +02:00
Mery-Sanz d7fc9c39a2 add tree 2025-05-14 13:40:25 +02:00
lidia9 3c0a948791 modifs 2025-05-14 13:37:20 +02:00
Mery-Sanz 8a85f0501d update /load 2025-05-14 13:16:37 +02:00
Mery-Sanz 6f91f64ffd tree 2025-05-14 13:00:23 +02:00
lidia9 8ce4191b63 modifs 2025-05-14 12:59:21 +02:00
Mery-Sanz d9797d4553 add patterns 2025-05-14 12:37:39 +02:00
lidia9 1a08874c6a modifs 2025-05-14 12:19:51 +02:00
Mery-Sanz 437c0322cc review doc 2025-05-14 12:14:33 +02:00
lidia9 7344d7a1bd modif 2025-05-14 12:11:23 +02:00
Mery-Sanz 06b05ad071 Merge branch 'docs_new' of https://gitlab.com/aliasrobotics/alias_research/cai into docs_new 2025-05-14 12:06:17 +02:00
Mery-Sanz bb8df175ce tools api 2025-05-14 12:06:08 +02:00
lidia9 5748cc8641 dev 2025-05-14 12:05:30 +02:00
lidia9 425052dfef modifs 2025-05-14 11:59:02 +02:00
lidia9 956ad1976c modifs 2025-05-14 11:56:27 +02:00
Mery-Sanz c6ca69e219 restructure 2025-05-14 11:25:55 +02:00
Mery-Sanz 698a23e818 new brnach 2025-05-14 11:18:48 +02:00
Víctor Mayoral Vilches 04ad6de2c8 Add minor updates in docs
Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>
2025-05-12 11:48:24 +02:00
Víctor Mayoral Vilches 47bd38b4aa Fix docs
Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>
2025-04-02 16:48:23 +02:00
Víctor Mayoral Vilches d3b6f8a1ed Merge remote-tracking branch 'origin/main' into cai 2025-03-31 13:21:34 +02:00
Eric Peter 9c53abe8c1
Databricks MLflow tracing integration (#401) 2025-03-30 23:53:09 -04:00
Víctor Mayoral Vilches 27d5316a60 Fix paths in docs
Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>
2025-03-28 08:35:25 +01:00
Víctor Mayoral Vilches 82054a2e1c Fix docs
Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>
2025-03-28 07:55:41 +01:00
Ali Waleed 382500d841
Add Langtrace to `tracing.md` (#371) 2025-03-27 21:33:49 -04:00
Víctor Mayoral Vilches 34a7bad920 Re-structure under sdk/agents, get CLI mockup
Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>
2025-03-27 14:31:38 +01:00
Rohan Mehta f99fa5f23c
Tracing screenshot for MCP docs (#355) 2025-03-26 10:56:34 -07:00
Víctor Mayoral Vilches c64f35eda6 Update docs to integrate CAI, minor refinements
Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>
2025-03-26 12:41:45 +01:00
Rohan Mehta dd881eed9a
feat: Add Graphviz-based agent visualization functionality (#147)
This pull request introduces functionality for visualizing agent
structures using Graphviz. The changes include adding a new dependency,
implementing functions to generate and draw graphs, and adding tests for
these functions.

New functionality for visualizing agent structures:

* Added `graphviz` as a new dependency in `pyproject.toml`.
* Implemented functions in `src/agents/visualizations.py` to generate
and draw graphs for agents using Graphviz. These functions include
`get_main_graph`, `get_all_nodes`, `get_all_edges`, and `draw_graph`.

Testing the new visualization functionality:

* Added tests in `tests/test_visualizations.py` to verify the
correctness of the graph generation and drawing functions. The tests
cover `get_main_graph`, `get_all_nodes`, `get_all_edges`, and
`draw_graph`.

For example, given the following code:

```python
from agents import Agent, function_tool
from agents.visualizations import draw_graph


@function_tool
def get_weather(city: str) -> str:
    return f"The weather in {city} is sunny."


spanish_agent = Agent(
    name="Spanish agent",
    instructions="You only speak Spanish.",
)

english_agent = Agent(
    name="English agent",
    instructions="You only speak English",
)

triage_agent = Agent(
    name="Triage agent",
    instructions="Handoff to the appropriate agent based on the language of the request.",
    handoffs=[spanish_agent, english_agent],
    tools=[get_weather],
)


draw_graph(triage_agent)
```

Generates the following image:

<img width="614" alt="Screenshot 2025-03-13 at 18 36 23"
src="https://github.com/user-attachments/assets/d01fe502-6886-4efb-aaf8-c92e4524b0fe"
/>
2025-03-25 19:22:58 -04:00
Rohan Mehta 6be9b2a222
Update visualization.md 2025-03-25 13:34:45 -04:00
Martín Bravo 698fd69eb4 Update installation instructions for visualization dependency to use 'viz' 2025-03-25 18:29:55 +01:00
Rohan Mehta 6fb5792b77 Make the reset behavior on tool use configurable
## Summary:

#263 added this behavior. The goal was to prevent infinite loops when tool choice was set. The key change I'm making is:
1. Making it configurable on the agent.
2. Doing bookkeeping in the Runner to track this, to prevent mutating agents.
3. Not resetting the global tool choice in RunConfig.

## Test Plan:
Unit tests.
.
2025-03-25 13:29:32 -04:00
Rohan Mehta b98a6bd4ac [4/n] Add docs for MCP
Just adding docs.
-
2025-03-25 13:25:50 -04:00
Martín Bravo 900a97fa55 Merge branch 'main' of https://github.com/openai/openai-agents-python into feat/draw_graph 2025-03-25 16:58:01 +01:00
Rohan Mehta 927a29c56b
Fix potential infinite tool call loop by resetting tool_choice after … (#263)
# Fix potential infinite tool call loop by resetting tool_choice after
tool execution

## Summary

This PR fixes an issue where setting `tool_choice` to "required" or a
specific function name could cause models to get stuck in an infinite
tool call loop.

When `tool_choice` is set to force tool usage, this setting persists
across model invocations. This PR automatically resets `tool_choice` to
"auto" after tool execution, allowing the model to decide whether to
make additional tool calls in subsequent turns.

Unlike using `tool_use_behavior="stop_on_first_tool"`, this approach
lets the model continue processing tool results while preventing forced
repeated tool calls.

## Test plan

- Added tests to verify tool_choice reset behavior for both agent and
run_config settings
- Added integration test to verify the solution prevents infinite loops
- All tests pass

## Checks

- [x] I've added new tests for the fix
- [x] I've updated the relevant documentation (added comment in code)
- [x] I've run `make lint` and `make format`
- [x] I've made sure tests pass
2025-03-25 11:30:53 -04:00
Rohan Mehta 791a6f6812
Update quickstart.md 2025-03-23 17:56:55 -04:00
xianghuijin 8f2f76cb65 docs: Update tool_choice reset documentation to match implementation 2025-03-22 14:22:47 +08:00
Rohan Mehta 8d906f88f0
Fix code examples in voice pipeline quickstart docs (#277) 2025-03-21 21:44:14 -04:00
Rohan Mehta 486b4e87e5
[docs] fix annotation numbering in context management (#293)
Fix inconsistent numbering between code and explanatory annotations in
the context management documentation.
2025-03-21 19:33:30 -04:00
Scott Condron 13eca63732
Add Weights & Biases to tracing docs 2025-03-21 21:37:54 +00:00
Han Hwang Lim d56047be51 fix annotation numbering in context management
Fix inconsistent numbering between code and explanatory annotations in
the context management documentation.
2025-03-21 21:10:30 +00:00
James Hills fa1c3f40a1
fix line in guardrails 2025-03-21 15:58:34 -04:00
Rohan Mehta 851f0ce539
docs: add Langfuse to tracing documentation (#284) 2025-03-21 10:31:05 -04:00