Skip to content

Conversation

@copybara-service
Copy link

@copybara-service copybara-service bot commented Feb 11, 2026

refactor: Code clean up in BaseAgent

  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.

@copybara-service copybara-service bot force-pushed the test_868418459 branch 3 times, most recently from 92403c2 to ab8369c Compare February 11, 2026 14:23
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
@copybara-service copybara-service bot merged commit 8a1fffa into main Feb 11, 2026
@copybara-service copybara-service bot deleted the test_868418459 branch February 11, 2026 14:28
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.

1 participant