Improve AgentBuilder: Avoid modifying original config dict

Open
#508 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
58/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Stale
Tech stack
python
Domain
backend

Research direction

Start in veadk/agent_builder.py at AgentBuilder._build() and trace how sub_agents and tools are extracted from the configuration. Done means repeatedly building with the same configuration leaves the caller’s dictionary unchanged; check for focused tests in the repository or add a regression test for that behavior.

Written by the indexing model from the issue text.

Description

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)
Dominant language
Python
Stars
344
Forks
98
Avg merge
8h 17m
Merged PRs (30d)
152

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from volcengine/veadk-python

All issues in volcengine/veadk-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.