lauren-framework/lauren-ai/agent-step-logging

Claude Code and agent skill by lauren-framework/lauren-ai

Trust tier 3
  • community
  • ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Source check pending

Checking that the SKILL.md file is still in the repository.

Log each agentic loop step using lifecycle hooks on the @agent class. Use when you need structured per-step logs for debugging, auditing, or monitoring without modifying the runner or adding external infrastructure.

Install

npx vskill@latest install lauren-framework/lauren-ai/agent-step-logging

Semi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard

SKILL.md

The same SKILL.md was published earlier as lauren-framework/lauren-ai/agent-step-logging.

Use codemap find "AgentContext" to check the lifecycle hook signatures.

Agent Execution Step Logging

Define on_start, on_turn_complete, on_tool_result, and on_finish lifecycle hooks on your @agent()-decorated class to log each step.

Hook signatures

HookParametersCalled when
on_start(ctx: AgentContext)Before first LLM call
on_turn_complete(completion: Completion, ctx: AgentContext)After each LLM call
on_tool_result`(result: ToolResult, ctx: AgentContext) -> ToolResult \None`After each tool execution
on_finish(response: AgentResponse, ctx: AgentContext)After the run completes

Pattern

python
import logging
from lauren_ai import agent, use_tools
from lauren_ai._agents import AgentContext, AgentResponse
from lauren_ai._transport import Completion
from lauren_ai._tools import ToolResult
logger = logging.getLogger(__name__)
@agent(model="claude-sonnet-4-6", system="You are a helpful assistant.")
class LoggingAgent:
async def on_start(self, ctx: AgentContext) -> None:
logger.info("Agent started: run_id=%s turn=%d", ctx.agent_run_id, ctx.turn)
async def on_turn_complete(self, completion: Completion, ctx: AgentContext) -> None:
logger.info(
"Turn %d complete: stop_reason=%s tokens_out=%d",
ctx.turn,
completion.stop_reason,
completion.usage.output_tokens,
)
async def on_tool_result(self, result: ToolResult, ctx: AgentContext) -> ToolResult | None:
logger.info(
"Tool %s result: is_error=%s",
result.tool_use_id,
result.is_error,
)
return None # return None to leave result unchanged
async def on_finish(self, response: AgentResponse, ctx: AgentContext) -> None:
logger.info(
"Agent finished: turns=%d total_in=%d total_out=%d",
response.turns,
response.total_usage.input_tokens,
response.total_usage.output_tokens,
)

Capture logs in tests

Use a list-based handler to assert on log output without configuring a real logging destination:

python
import logging
class ListHandler(logging.Handler):
def __init__(self):
super().__init__()
self.records: list[str] = []
def emit(self, record):
self.records.append(self.format(record))
handler = ListHandler()
logging.getLogger("myapp.agents").addHandler(handler)
logging.getLogger("myapp.agents").setLevel(logging.INFO)

Or use pytest's built-in caplog fixture:

python
@pytest.mark.asyncio
async def test_hooks_called(caplog):
with caplog.at_level(logging.INFO):
response = await runner.run(agent_instance, "Hello")
assert any("Agent started" in r for r in caplog.messages)
assert any("Agent finished" in r for r in caplog.messages)

Notes

  • Hooks are optional — define only the ones you need.
  • on_tool_result returning None leaves the result unchanged; returning a

new ToolResult replaces it (useful for sanitising sensitive outputs).

  • Hooks run synchronously or asynchronously — both def and async def work.
  • The runner swallows hook exceptions (logging a warning) so a broken hook

never aborts the agent run.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Extension points

  • hookPre/post lifecycle hooks

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/lauren-framework/lauren-ai/agent-step-logging/badge)](https://verified-skill.com/skills/lauren-framework/lauren-ai/agent-step-logging)

Something wrong with this skill or its page? Tell us.