Skip to content

Improve AgentBuilder: Avoid modifying original config dict #508

@Lingbo-Huang

Description

@Lingbo-Huang

Problem Description

Currently, the AgentBuilder._build() method uses pop() operations which modify the original config dict, potentially causing:

  1. Side effects: If the caller retains a reference to the config, they'll find it unexpectedly modified
  2. Reusability issues: The same config object cannot be used multiple times
  3. Code clarity: The intent of pop() is not clear

Current Code

# veadk/agent_builder.py, line 46-63
if agent_config.get("sub_agents", None):
    for sub_agent_config in agent_config["sub_agents"]:
        agent = self._build(sub_agent_config)
        sub_agents.append(agent)
    agent_config.pop("sub_agents")  # ⚠️ Modifies original config

tools = []
if agent_config.get("tools", []):
    for tool in agent_config["tools"]:
        # ... tool processing
        tools.append(func)
    agent_config.pop("tools")  # ⚠️ Modifies original config

agent = agent_cls(**agent_config, sub_agents=sub_agents, tools=tools)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions