Python: Address PR 5331 comments and track sesssion while calling Agent in email_security_example (#5446)

* Address PR review: fix paths and update FIDES implementation

* Address PR comments and add session tracking in email example in samples

* Fix session creation and resolve merge conflict in docstring example

* Resolve merge conflict in docstring example
This commit is contained in:
shrutitople
2026-04-24 10:38:22 +01:00
committed by eavanvalkenburg
Unverified
parent 14d779c0fb
commit 9711562c9e
6 changed files with 37 additions and 195 deletions
@@ -278,7 +278,13 @@ async def run_scenarios(agent, config):
print("- Injection attempts in emails are NOT followed")
print()
response = await agent.run("Please fetch my recent emails and give me a brief summary of each one.")
# Use a shared session so conversation history persists across scenarios.
# Without this, each agent.run() starts a fresh conversation and the LLM
# won't know about the emails fetched in Scenario 1 — it would never
# attempt to call send_email, so the policy enforcer would never trigger.
session = agent.create_session()
response = await agent.run("Please fetch my recent emails and give me a brief summary of each one.", session=session)
print(f"\n📋 Agent Response:\n{'-' * 40}")
print(response.text)
@@ -295,7 +301,9 @@ async def run_scenarios(agent, config):
print("- Agent should explain it cannot send email due to security policy")
print()
response = await agent.run("Now please send an email to colleague@company.com summarizing what you found.")
response = await agent.run(
"Now please send an email to colleague@company.com summarizing what you found.", session=session
)
print(f"\n📋 Agent Response:\n{'-' * 40}")
print(response.text)