google / google/adk-python

Tracing end user input and agent output

Đang mở
#4,593 4 bình luận 0 reaction 1 người được giao Được @B-Step62 nhận Xem trên GitHub
needs review tracing
Ngôn ngữ chính
Python
Star
21.5k
Fork
4k
Merge trung bình
1 ngày 22 giờ
Pull request đã merge (30 ngày)
31

Mô tả

## 🔴 Required Information
*Please ensure all items in this section are completed to allow for efficient
triaging. Requests without complete information may be rejected / deprioritized.
If an item is not applicable to you - please mark it as N/A*

### Is your feature request related to a specific problem?

OpenTelemetry trace from Google ADK creates an empty root span and does not capture end user input and output.

Image

### Describe the Solution You'd Like

Optionally record user inputs and agent outputs to the `invocation` span created [here](https://github.com/google/adk-python/blob/7557a929398ec2a1f946500d906cef5a4f86b5d1/src/google/adk/runners.py#L494).

Alternatively, add a callback to the runner execution so we can customize the behavior. The agent callbacks does not help because they are executed after the span is created.

### Impact on your work

Only LLM spans include user input and agent output, which makes it tricky to process traces for downstream operations (e.g. review conversation sessions, evaluate traces, etc).

### Willingness to contribute
Yes. Happy to contribute if the proposal makes sense.

---

## 🟡 Recommended Information

### Describe Alternatives You've Considered

We could dreate a wrapper span and set inputs/outputs. However, invoking agent directly is not the primary way to run/deploy ADK agents. Also handling streaming event requires boilerplate code.

```
with tracer.start_as_current_span as span:
span.set_attributes("user_content", user_content)
async with Aclosing(ctx.agent.run_async(ctx)) as agen:
async for event in agen:
yield event
...
```

### Proposed API / Implementation

Add a new environment variable like `ADK_CAPTURE_END_USER_INPUTS_OUTPUTS` with default to `False`. When it is set, the end user inputs and outputs will be recorded in the root span.

### Additional Context
Add any other context or screenshots about the feature request here.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.