Skip to content

Commit 8e832de

Browse files
authored
Updated README with updated usage examples for new decorators and session management. Introduce session, agent, operation, task, and workflow decorators for improved observability. (#862)
1 parent c9faca8 commit 8e832de

File tree

1 file changed

+54
-18
lines changed

1 file changed

+54
-18
lines changed

README.md

Lines changed: 54 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -140,39 +140,75 @@ Add powerful observability to your agents, tools, and functions with as little c
140140
Refer to our [documentation](http://docs.agentops.ai)
141141

142142
```python
143-
# Automatically associate all Events with the agent that originated them
144-
from agentops import track_agent
143+
# Create a session span (root for all other spans)
144+
from agentops.sdk.decorators import session
145145

146-
@track_agent(name='SomeCustomName')
147-
class MyAgent:
148-
...
146+
@session
147+
def my_workflow():
148+
# Your session code here
149+
return result
149150
```
150151

151152
```python
152-
# Automatically create ToolEvents for tools that agents will use
153-
from agentops import record_tool
153+
# Create an agent span for tracking agent operations
154+
from agentops.sdk.decorators import agent
154155

155-
@record_tool('SampleToolName')
156-
def sample_tool(...):
157-
...
156+
@agent
157+
class MyAgent:
158+
def __init__(self, name):
159+
self.name = name
160+
161+
# Agent methods here
158162
```
159163

160164
```python
161-
# Automatically create ActionEvents for other functions.
162-
from agentops import record_action
165+
# Create operation/task spans for tracking specific operations
166+
from agentops.sdk.decorators import operation, task
163167

164-
@agentops.record_action('sample function being record')
165-
def sample_function(...):
166-
...
168+
@operation # or @task
169+
def process_data(data):
170+
# Process the data
171+
return result
167172
```
168173

169174
```python
170-
# Manually record any other Events
171-
from agentops import record, ActionEvent
175+
# Create workflow spans for tracking multi-operation workflows
176+
from agentops.sdk.decorators import workflow
172177

173-
record(ActionEvent("received_user_input"))
178+
@workflow
179+
def my_workflow(data):
180+
# Workflow implementation
181+
return result
174182
```
175183

184+
```python
185+
# Nest decorators for proper span hierarchy
186+
from agentops.sdk.decorators import session, agent, operation
187+
188+
@agent
189+
class MyAgent:
190+
@operation
191+
def nested_operation(self, message):
192+
return f"Processed: {message}"
193+
194+
@operation
195+
def main_operation(self):
196+
result = self.nested_operation("test message")
197+
return result
198+
199+
@session
200+
def my_session():
201+
agent = MyAgent()
202+
return agent.main_operation()
203+
```
204+
205+
All decorators support:
206+
- Input/Output Recording
207+
- Exception Handling
208+
- Async/await functions
209+
- Generator functions
210+
- Custom attributes and names
211+
176212
## Integrations 🦾
177213

178214
### OpenAI Agents SDK 🖇️

0 commit comments

Comments
 (0)