Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,10 @@ Note that requests that time out are [retried twice by default](#retries).

We use the standard library [`logging`](https://docs.python.org/3/library/logging.html) module.

You can enable logging by setting the environment variable `LLAMA_STACK_LOG` to `debug`.
You can enable logging by setting the environment variable `LLAMA_STACK_CLIENT_LOG` to `debug`.

```shell
$ export LLAMA_STACK_LOG=debug
$ export LLAMA_STACK_CLIENT_LOG=debug
```

### How to tell whether `None` means `null` or missing
Expand Down
3 changes: 3 additions & 0 deletions src/llama_stack_client/lib/agents/event_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ def log(self, event_generator: Iterator[AgentStreamChunk]) -> Iterator[str]:
for resp in result.tool_responses:
tool_name = resp.get("tool_name", "unknown")
content = resp.get("content", "")
if content is None or content == "":
yield f" → {tool_name}\n"
continue
# Truncate long responses for readability
if isinstance(content, str) and len(content) > 100:
content = content[:100] + "..."
Expand Down
35 changes: 35 additions & 0 deletions tests/lib/agents/test_event_logger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree.

from llama_stack_client.lib.agents.event_logger import AgentEventLogger
from llama_stack_client.lib.agents.turn_events import StepCompleted, ToolExecutionStepResult


def test_agent_event_logger_omits_empty_tool_response_fields() -> None:
event = StepCompleted(
step_id="step_empty_fields",
step_type="tool_execution",
turn_id="turn_empty_fields",
result=ToolExecutionStepResult(
step_id="step_empty_fields",
tool_calls=[],
tool_responses=[
{"tool_name": "no_content_tool", "content": ""},
{"tool_name": "null_content_tool", "content": None},
{"tool_name": "valid_content_tool", "content": "abc"},
],
),
)

logger = AgentEventLogger()
messages = list(logger.log(iter([event])))

assert messages == [
" → no_content_tool\n",
" → null_content_tool\n",
" → valid_content_tool: abc\n",
]