Metadata-Version: 2.5
Name: adk-neomundi
Version: 0.1.0
Summary: Measure a Google ADK agent's model calls with NeoMundi, over OpenTelemetry
Project-URL: Homepage, https://github.com/neomundi-io/neomundi-integrations
Project-URL: Source, https://github.com/neomundi-io/neomundi-integrations/tree/main/integrations/adk
Author: NeoMundi
License-Expression: Apache-2.0
Keywords: agents,genai,google-adk,neomundi,opentelemetry
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: System :: Monitoring
Requires-Python: >=3.11
Requires-Dist: google-adk<3,>=2.15.1
Requires-Dist: otel-neomundi<0.3,>=0.2.0
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == 'dev'
Description-Content-Type: text/markdown

# adk-neomundi

Measure the model calls of a **Google ADK** agent with NeoMundi, over the
OpenTelemetry spans ADK already emits.

> 🔴 **Not published.** This package is not on PyPI, and publication is
> blocked by a `Private :: Do Not Upload` classifier. It also depends on
> `otel-neomundi>=0.2.0`, which is not published either.

## What it is, and what it is not

🔴 **This package is deliberately thin.** It is **two ADK callbacks and a
one-slot mailbox**. The span processor, the `Outcome`, the parentage, the closed
set of refusals, the deferred close and the model-to-tool join all live in
[`otel-neomundi`](../otel/README.md) and are **imported**.

⚠ **Why that matters**: none of those pieces knows anything about Google. A
copy of them in a package named `adk-neomundi` would make the next host pay for
it twice.

## 🔴 Install: you cannot, yet

**This package is not on PyPI, so there is no install command to copy.** Writing
one here would hand a reader a line that fails — which is why
`tools/check_conformance.py` refuses a copyable `pip install` for a package
whose manifest says `published_on: none`. ⚠ **It caught exactly that in a first
draft of this file.**

**Two things must happen first, in this order:**

1. **`otel-neomundi` 0.2.0 is published.** 🔴 This package depends on it and
   carries **no copy** of what it provides;
2. the `Private :: Do Not Upload` classifier is removed from
   `pyproject.toml`, in a **separate, approved activation commit**.

Until then, read it from the repository.

## Use

```python
from opentelemetry.sdk.trace import TracerProvider
from otel_neomundi import NeoMundiSpanProcessor, join
from adk_neomundi import callbacks

provider = TracerProvider()
# Start here: submit=False needs no key and opens no socket.
processor = NeoMundiSpanProcessor(submit=False, tracer_provider=provider)
provider.add_span_processor(processor)

before, after, mailbox = callbacks(processor)

agent = LlmAgent(
    name="validator",
    model="gemini-3.5-flash-lite",
    tools=[validate_address],
    before_model_callback=before,
    after_model_callback=after,
)
```

The `Outcome` arrives on `processor.outcomes` **after ADK ends its model span**,
which is later than the end of any callback -- that is the whole reason
`close_on_model_span=True` exists.

### Reading the tool result the model consumed

```python
for outcome in processor.outcomes:
    verdict = join(spans, trace_id=outcome.trace_id, model_span_id=outcome.span_id)
    if verdict.joined:
        print(verdict.tool_name, verdict.result)
    else:
        print("refused:", verdict.refusal)  # never a guess
```

🔴 **This needs `OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=SPAN_ONLY`.**
⚠ **And that switch puts tool content on spans**: if your tool handles personal
data, so does your telemetry. Decide it on purpose.

⚠ **The value `true` does NOT work for this.** It resolves to `EVENT_ONLY` --
content on the log record, **not** on the span. Reported upstream:
[google/adk-python#8432](https://github.com/google/adk-python/issues/8432).

## What it refuses to do

- submit a token count **read from a span** -- only the one the provider returned;
- measure a **second** model call while one is pending: the mailbox **refuses**,
  and `mailbox.refused` counts it. ⚠ **Read that number**: non-zero means turns
  ran unmeasured;
- defer an interaction in which the **application raised**;
- guess **which** tool result a model call consumed when several are candidates.

## Before you draw a conclusion

Read [`LIMITATIONS.md`](LIMITATIONS.md). Evidence level is **E1**: offline tests
only. 🔴 **No real provider call has been made.**
