Skip to content

Add AutoGen integration (auto-instrumentation + Penelope Target) - #2008

Open
Ayush7614 wants to merge 2 commits into
rhesis-ai:mainfrom
Ayush7614:feature/autogen-integration
Open

Add AutoGen integration (auto-instrumentation + Penelope Target)#2008
Ayush7614 wants to merge 2 commits into
rhesis-ai:mainfrom
Ayush7614:feature/autogen-integration

Conversation

@Ayush7614

@Ayush7614 Ayush7614 commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Purpose

Complete AutoGen SDK auto-instrumentation and add a Penelope target so users can observe and test AutoGen agents automatically.

Closes #1866

What Changed

  • Implemented AutoGenIntegration with generate_reply / a_generate_reply patching and OTel spans (model, tokens, latency, I/O)
  • Added shared tracing_helpers.py for framework integration span utilities
  • Added AutoGenTarget wrapping ConversableAgent with per-conversation_id history
  • Exported AutoGenTarget from Penelope targets and added autogen optional dependency
  • Added SDK and Penelope unit tests

Testing

  • cd sdk && uv run pytest ../tests/sdk/telemetry/integrations/test_autogen_integration.py ../tests/sdk/telemetry/integrations/test_langgraph_integration.py -q
  • cd penelope && uv run pytest ../tests/penelope/targets/test_autogen.py -q

Implement AutoGenIntegration with generate_reply patching for automatic
telemetry, add AutoGenTarget for multi-turn Penelope testing, and add
unit tests for issue rhesis-ai#1866.

@peqy peqy Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AutoGen integration/target looks solid overall and tests cover the basics.

Main things to address:

  • Penelope AutoGenTarget currently drops files silently (either support or explicitly error).
  • AutoGenTarget leaves history mutated on exceptions.
  • Token attributes helper drops explicit 0s.
  • penelope[all] doesn’t include the new autogen extra.

Found 4 issues (0 critical, 4 improvements).

self,
message: str,
conversation_id: Optional[str] = None,
files: Optional[List] = None,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improvement files is part of the Target interface, but it’s currently ignored.

Fix: either explicitly reject with a clear error (so callers don’t think attachments were used), or map/forward files into AutoGen’s expected input format if supported.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Addressed in 0dee4a7: send_message() now explicitly rejects files with a clear error and does not call the agent.

"session_messages_count": len(history),
},
)
except Exception as exc:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improvement On exception, the user message has already been appended to history, so a transient failure will leave the conversation state “ahead” by one turn.

Fix: consider rolling back the last user entry on failure (or explicitly record an error turn), and include conversation_id=session_key in the error TargetResponse for consistency.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Addressed in 0dee4a7: on exception the last user turn is rolled back and the error TargetResponse includes conversation_id=session_key.

return
try:
prompt, completion, total = extract_token_usage(usage)
if prompt:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improvement set_token_attributes() only sets attributes when counts are truthy, so explicit 0 token values are dropped.

Other integrations in this repo tend to set 0s when usage is present.

Fix: use is not None checks (or set all 3 when any usage is present) so 0 is recorded consistently.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Addressed in 0dee4a7: set_token_attributes() now records explicit 0 token counts when usage is provided (test added).

Comment thread penelope/pyproject.toml
autogen = [
"pyautogen>=0.2.0",
]
all = [

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improvement autogen optional extra isn’t included in the all extra.

Fix: add pyautogen>=0.2.0 to all if all is meant to truly enable every target/integration.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Addressed in 0dee4a7: pyautogen>=0.2.0 is now included in the all extra.

Reject unsupported file attachments explicitly, roll back session history
on generate_reply failures, record zero token counts, and include
pyautogen in penelope[all].
@peqy

peqy Bot commented Jun 19, 2026

Copy link
Copy Markdown

Reviewed latest commit 0dee4a7. The previously flagged issues (files handling, rollback on exception + conversation_id, token 0s, all extra) are all addressed.

No new issues spotted in the updated diff. Ship it.

@Ayush7614

Copy link
Copy Markdown
Contributor Author

cc: @harry-rhesis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add AutoGen integration (auto-instrumentation + Penelope Target)

1 participant