Skip to content

Conversation

@copybara-service
Copy link

refactor: refactors parts of the ADK codebase to improve null safety 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.

…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: 863294916
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