Skip to content

Commit 903d016

Browse files
committed
docs: enhance DEVELOPMENT.md with profiling usage example and update log level default in Agent class
1 parent 3fb72f0 commit 903d016

File tree

3 files changed

+2632
-2584
lines changed

3 files changed

+2632
-2584
lines changed

DEVELOPMENT.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,43 @@ start_http_server(port=9464)
301301

302302
You can now see the metrics at `http://localhost:9464/metrics` (make sure that your Python program keeps running), after this you can setup your Prometheus server to scrape this endpoint.
303303

304+
### Profiling
305+
306+
The `Profiler` class uses `pyinstrument` to profile your agent's performance and generate an HTML report showing where time is spent during execution.
307+
308+
#### Example usage:
309+
310+
```python
311+
from uuid import uuid4
312+
from vision_agents.core import User, Agent
313+
from vision_agents.core.profiling import Profiler
314+
from vision_agents.plugins import getstream, gemini, deepgram, elevenlabs, vogent
315+
316+
async def start_agent() -> None:
317+
agent = Agent(
318+
edge=getstream.Edge(),
319+
agent_user=User(name="My AI friend", id="agent"),
320+
instructions="You're a helpful assistant.",
321+
llm=gemini.LLM("gemini-2.0-flash"),
322+
tts=elevenlabs.TTS(),
323+
stt=deepgram.STT(),
324+
turn_detection=vogent.TurnDetection(),
325+
profiler=Profiler(output_path='./profile.html'), # Optional: specify output path
326+
)
327+
328+
call = agent.edge.client.video.call("default", str(uuid4()))
329+
with await agent.join(call):
330+
await agent.simple_response("Hello!")
331+
await agent.finish()
332+
```
333+
334+
The profiler automatically:
335+
- Starts profiling when the agent is created
336+
- Stops profiling when the agent finishes (on `AgentFinishEvent`)
337+
- Saves an HTML report to the specified output path (default: `./profile.html`)
338+
339+
You can open the generated HTML file in a browser to view the performance profile, which shows a timeline of function calls and where time is spent during agent execution.
340+
304341

305342
### Queuing
306343

agents-core/vision_agents/core/agents/agents.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def __init__(
155155
options: Optional[AgentOptions] = None,
156156
tracer: Tracer = trace.get_tracer("agents"),
157157
# Configure the default logging for the sdk here. Pass None to leave the config intact.
158-
log_level: Optional[int] = logging.DEBUG,
158+
log_level: Optional[int] = logging.INFO,
159159
profiler: Optional[Profiler] = None,
160160
):
161161
if log_level is not None:

0 commit comments

Comments
 (0)