Skip to content

Fix upstream merge 128#130

Merged
Sandeep-BA merged 65 commits intomainfrom
fix-upstream-merge-128
Feb 17, 2026
Merged

Fix upstream merge 128#130
Sandeep-BA merged 65 commits intomainfrom
fix-upstream-merge-128

Conversation

@Sandeep-BA
Copy link
Collaborator

No description provided.

google-genai-bot and others added 30 commits January 28, 2026 07:45
PiperOrigin-RevId: 862232259
This is going to be a useful feature for rewind

PiperOrigin-RevId: 862232441
This CL integrates event compaction configuration into the InvocationContext, allowing agent to access the configs during execution.

PiperOrigin-RevId: 862366865
PiperOrigin-RevId: 862713740
…nfig

This interface change allows intra-invocation compaction with configurable trigger threshold and number of events to be preserved from being compacted.

PiperOrigin-RevId: 863086157
PiperOrigin-RevId: 864223068
reducing cyclical dependencies would help create something akin to "adk-light"

PiperOrigin-RevId: 864316690
The `saveAndReloadArtifact()` enables a save without a second i/o call just to get the full file path.

PiperOrigin-RevId: 864659692
… tail of the event stream

Provide a way to manage the size of an event stream

Specifically, it:

* Keeps the retentionSize most recent events raw.
* Compacts all events that never compacted and older than the retained tail, including the most recent compaction events, into a new summary event.
* Appends this new summary event to the end of the event stream.

PiperOrigin-RevId: 864748009
…and consistency

This CL refactors parts of the ADK codebase to improve null safety and consistency. The main changes include:

1.  **`BaseAgent`**:
    *   `beforeAgentCallback` and `afterAgentCallback` fields and their accessors now use `ImmutableList` (defaulting to empty) instead of `Optional<List>`.
    *   `findAgent` and `findSubAgent` now return `Optional<BaseAgent>`, with `findSubAgent` being reimplemented using Java Streams.

2.  **`BaseAgentConfig`**: Getters for `subAgents`, `beforeAgentCallbacks`, and `afterAgentCallbacks` now return an empty list if the underlying field is null.

3.  **`CallbackUtil`**: `getBeforeAgentCallbacks` and `getAfterAgentCallbacks` return `ImmutableList.of()` instead of `null` for null inputs.

4.  **`LlmAgent`**: The `codeExecutor()` method now returns `Optional<BaseCodeExecutor>`.

These changes necessitate updates in `BaseLlmFlow`, `CodeExecution`, and `Runner` to handle the new `Optional` return types.

PiperOrigin-RevId: 864883202
This change ensures the trace context is propagated across asynchronous boundaries for LLM and Tool calls.

PiperOrigin-RevId: 865572112
PiperOrigin-RevId: 865975883
…Python ADK

This change introduces ContextCacheConfig, a configuration class for enabling and controlling context caching across all agents within an ADK application. The App class is updated to include an optional ContextCacheConfig, allowing applications to specify caching parameters such as cache intervals, TTL, and minimum token thresholds for caching.

PiperOrigin-RevId: 866030713
This allows callbacks and tools to know which event triggered them.  This is useful in telemetry and tracing.

PiperOrigin-RevId: 866050613
PiperOrigin-RevId: 866059790
Wonder if we can downgrade those two info() level loggings. They make viewing information from our debugger CLI very difficult.

PiperOrigin-RevId: 866158204
tilgalas and others added 29 commits February 9, 2026 03:26
A single LiveServerMessage is now converted to a series of LlmResponse
messages each corresponding to a different part of the
LiveServerMessage, notably the UsageMetadata field is now converted to
a GenerateResponseUsageMetadata and emitted downstream.

PiperOrigin-RevId: 867516050
PiperOrigin-RevId: 868014417
…istory

reinstating the fix in google#682 which was later reverted in google#827

PiperOrigin-RevId: 868043103
PiperOrigin-RevId: 868170491
PiperOrigin-RevId: 868235383
This update should make the java tracing consistent with Python ADK:

1.  **`BaseAgent.java`**:
    *   The `runAsync` and `runLive` methods have been modified to create the `InvocationContext` before starting the tracing span.
    *   The span name for agent invocations has been changed from `"agent_run [<agent name>]"` to `"invoke_agent <agent name>"`.
    *   A new `Tracing.traceAgentInvocation` method is now called to add initial tracing attributes for the agent invocation.
    *   In `runLive`, the `runLiveImpl` execution is now wrapped with calls to `beforeAgentCallback` and `afterAgentCallback` to ensure proper tracing of these lifecycle events.

2.  **`Tracing.java`**:
    *   The OpenTelemetry tracer name has been updated from `"com.google.adk"` to `"gcp.vertex.agent"`.
    *   A new `traceAgentInvocation` method has been added to set standard attributes for agent invocation spans, including `gen_ai.operation.name`, `gen_ai.agent.description`, `gen_ai.agent.name`, and `gen_ai.conversation.id`.
    *   Attribute keys used in `traceToolCall`, `traceToolResponse`, `traceCallLlm`, and `traceSendData` have been updated to use the `"gcp.vertex.agent."` prefix instead of `"adk."` or `"com.google.adk"`.
    *   The serialization of message content (like tool call arguments, tool responses, and data) is now guarded by the `CAPTURE_MESSAGE_CONTENT_IN_SPANS` flag. When disabled, empty JSON objects are recorded instead.
    *   `traceToolResponse` now includes logic to extract and trace the `tool_call.id` and the tool response content from `FunctionResponse` objects.
    *   `traceCallLlm` now captures additional LLM request and response details, such as `gen_ai.request.top_p`, `gen_ai.request.max_tokens`, `gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`, and `gen_ai.response.finish_reasons`.

PiperOrigin-RevId: 868299966
This change introduces ContextCacheConfig to the InvocationContext and Runner classes, allowing context cache settings to be configured per invocation.

PiperOrigin-RevId: 868315679
Python and Vertex Session Store moved to use endOfAgent, so we should use that as well.

PiperOrigin-RevId: 868587270
This testing found an improvement in how span propogation works in Function Calling.

I would like to do a significant refactoring to cleanup all of the sprinkled tracing code.  This step is necessary to confirm proper behavior before the refactor.

PiperOrigin-RevId: 868623517
1.  **Extracting Common Run Logic:** A new private method `run` is introduced to encapsulate the common setup and execution flow shared by both `runAsync` and `runLive`. This includes creating the `InvocationContext`, setting up tracing, and handling before/after callbacks.
2.  **Reducing Duplication:** Both `runAsync` and `runLive` now call this new `run` method, passing their specific implementation (`runAsyncImpl` or `runLiveImpl`) as a function. This eliminates a significant amount of duplicated code.
3.  **Minor Cleanups:**
    *   The `createInvocationContext` method now uses `parentContext.branch().filter(...).ifPresent(...)` for a more concise optional handling.
    *   An unnecessary `agentCallbacks == null` check is removed from `callCallback`, as the list should not be null.

PiperOrigin-RevId: 868646905
…cation_id',

'agent', and 'session' fields

PiperOrigin-RevId: 868688936
Map<String, Integer> now matches with Vertex AI Session API and the python  artifactDelta implementation.  The new implementation unblocks rewind functionality.

Background:
- Artifact service stores artifacts with a key like `{app}_{user}_{sessionId}_{file}_{version}`
- Session service has the app, user, session id. It saves EventAction with an economic `[file] : [version]` map.  The Python ADK always had it this way, and somehow Java diverged.
PiperOrigin-RevId: 869350765
The ADK Python code has pause/resume/rewind functionality.  It's going to be some time before ADK Java gets it.  For now, it's worth cleaning up the half-baked feature.

PiperOrigin-RevId: 869384320
PiperOrigin-RevId: 869697412
PiperOrigin-RevId: 869704217
Refactor the tracing implementation within the Google ADK to simplify how OpenTelemetry spans are managed, especially within RxJava streams.

The key changes include:

1.  **Introducing `Tracing.TracerProvider`**: A new set of RxJava transformers (`FlowableTransformer`, `SingleTransformer`, `MaybeTransformer`, `CompletableTransformer`) is added in `Tracing.java`. These transformers, created via `Tracing.trace()` methods, handle the lifecycle of OpenTelemetry spans, including span creation, making the span current, and ending the span upon stream completion or error.

2.  **Simplifying Tracing Calls**: Instead of manually creating and managing spans with `Tracer`, `Span`, and `Scope`, various parts of the codebase now use the `.compose(Tracing.trace(...))` operator on RxJava streams. This is applied in:
    *   `BaseAgent.java`: For agent invocations using `Tracing.traceAgent`.
    *   `BaseLlmFlow.java`: For LLM calls (`call_llm`) and sending data (`send_data`).
    *   `Functions.java`: For tool responses and tool calls.
    *   `Runner.java`: For overall invocation spans in `runAsync` and `runLive`.

3.  **Centralized Attribute Setting**: Helper methods like `getValidCurrentSpan`, `setInvocationAttributes`, `setToolExecutionAttributes`, and `setJsonAttribute` are added to `Tracing.java` to encapsulate and standardize how attributes are set on spans, including handling JSON serialization and checks for valid spans.

These changes aim to reduce tracing-related boilerplate, improve consistency, and make the tracing logic more robust by tying span lifetimes to RxJava stream lifecycles.

PiperOrigin-RevId: 869714739
PiperOrigin-RevId: 869797377
@Sandeep-BA Sandeep-BA merged commit 8467224 into main Feb 17, 2026
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants