Skip to content

feat: replace positional tools array with named tool_config dict#398

Open
Davsooonowy wants to merge 24 commits into
mainfrom
feature/ent-283-refactor-tool-configuration-model
Open

feat: replace positional tools array with named tool_config dict#398
Davsooonowy wants to merge 24 commits into
mainfrom
feature/ent-283-refactor-tool-configuration-model

Conversation

@Davsooonowy
Copy link
Copy Markdown
Contributor

@Davsooonowy Davsooonowy commented May 15, 2026

Summary

  • Fixes agentic execution crash: StopExecutionTool is appended to the tool list at runtime but had no corresponding entry in the positional tools array stored in DB config — causing an index-out-of-range crash. Named lookup silently skips tools with no config entry.
  • Eliminates positional coupling: Agent tool config is now stored as tool_config: {"tool_name": {...}} (keyed by tool.NAME) instead of tools: [{...}, {}] (positional array). Order of tools in the runtime list no longer matters.
  • Frontend updated: Config form handles two-level nesting for tool_config, including flatten/unflatten, default values, build-back to API payload, and server error mapping.

Changes

Backend:

  • BaseAgent.set_runtime_arguments — named tool_config.get(tool.NAME) lookup replaces positional index loop
  • AgentPreconfigurationService._build_default_agent_configuration — builds tool_config dict (skips tools with no CONFIGURATION_ARGS)
  • New PydanticModelToolConfigField validates dict-keyed tool config against each tool's Pydantic schema
  • AgentConfigSerializer + AgentChoiceSerializer + AgentTypesView updated to use tool_config
  • verifyagents management command updated to validate by name instead of index

Frontend:

  • AgentConfig and AgentChoice types updated (tool_config dict replaces tools array)
  • flattenConfigForForm handles 2-level tool_config nesting → tool_config_${toolName}_${fieldName} flat keys
  • Hook and form component updated: default values, build-back, error parsing, rendering with per-tool labels

Breaking Change

No DB migration. Existing agent configs with the old tools: [...] format are incompatible. Agents must be re-preconfigured after deploy (run ./manage.py preconfiguregents or equivalent).

Replace the positional tools list with a named tool_config dict (keyed
by tool NAME) throughout the serializer, view, and preconfiguration
service layers. Also fix a circular import in enthusiast-common caused
by agents/config.py importing AgentConfig at module load time.
Rename CONFIGURATION to CONFIGURATION_ARGS on DummyTool, DummyTool2, and
NoConfigTool in test_fields.py, and update all tool_field_name arguments to
match the real BaseTool attribute name used in production. Add
test_verifyagents_command_missing_tool_name_in_tool_config to cover the branch
where a required tool key is entirely absent from tool_config.
Replace bare DummyTool class references with FunctionToolConfig(tool_class=DummyTool)
in two tests so fixtures are structurally correct and guard-order-independent.
Also add blank lines to separate Arrange/Act/Assert sections in
test_verifyagents_command_missing_tool_name_in_tool_config.
…oolListField, broaden verifyagents exception handling
- fields.py: wrap unknown-tool error in a list so DRF serialises it correctly
- form-utils.ts: use raw section key instead of sectionMapping alias in tool_config branch
- verifyagents.py: catch AttributeError alongside ValidationError and TypeError
- test_fields.py: assert unknown-tool error is a list
…IGURATION_ARGS

- agents.ts: use ExtraArgDetail instead of string for tool_config values, consistent with AgentConfig in types.ts
- fields.py: include all named tools in tool_map regardless of CONFIGURATION_ARGS; tools without a schema are accepted silently instead of raising Unknown tool
- test_fields.py: update test to assert silent acceptance instead of error
@Davsooonowy Davsooonowy self-assigned this May 19, 2026
@Davsooonowy Davsooonowy marked this pull request as ready for review May 19, 2026 12:48
@Davsooonowy Davsooonowy added v2.0 feat New feature labels May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat New feature v2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant