Skip to content

feat: wire lex-log into agent/tool execution for distributed tracing #16

Description

@alpibrupa

Current state

lex-trail is integrated (session events logged via trail_log). lex-log is NOT integrated — agent execution, tool calls, and LLM steps produce no spans or metrics.

Gap

lex-code is observability-dark at runtime:

  • No span per agent turn (can't measure latency, identify slow tools)
  • No metrics on tool success/failure rates
  • No distributed trace correlation for multi-agent scenarios (multi_agent.lex)
  • No log correlation between LLM steps and trail events

This means humans monitoring deployed lex-code instances can't verify runtime behaviour without reading logs — undermining the trust model.

What to add

Using lex-log/instrument.lex (already exists):

1. Per-turn span in session.lex

let scope := instrument.a2a_begin(ctx, session.id)
let result := run_turn_impl(session, input, provider_tag)
let scope2 := instrument.a2a_finish(scope, result.ok)

2. Per-tool-call span in agent dispatch

Each tool execution in lex-llm/agent.lex's dispatch loop should emit:

  • span.start("tool.execute") with tool_name attr
  • span.finish on completion with success attr

3. Metrics

  • counter("tool.calls", [("tool", name), ("success", "true|false")])
  • histogram("turn.duration_ms") per agent turn

4. Multi-agent trace propagation

multi_agent.lex spawns impl + test agents concurrently. Each should carry the parent trace context so their spans appear as children in the distributed trace.

Configuration

OTel export should be opt-in via env: LEX_OTLP_ENDPOINT=http://localhost:4318 (stdout JSON-lines if unset).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions