Skip to content

feat: add dict-like .get() method to AgentConfig dataclass#1421

Closed
gdeyoung wants to merge 1 commit intoagent0ai:mainfrom
gdeyoung:feature/agentconfig-get-method
Closed

feat: add dict-like .get() method to AgentConfig dataclass#1421
gdeyoung wants to merge 1 commit intoagent0ai:mainfrom
gdeyoung:feature/agentconfig-get-method

Conversation

@gdeyoung
Copy link
Copy Markdown
Contributor

@gdeyoung gdeyoung commented Apr 2, 2026

Summary

Adds a .get(key, default) method to the AgentConfig dataclass to provide dict-like access to config attributes.

Problem

AgentConfig is a @DataClass used throughout the framework as a configuration object. Extensions, skills, and external tools often receive config objects and expect dict-like .get() access with default values.

Without this method, code that calls config.get('key', default) raises:

AttributeError: 'AgentConfig' object has no attribute 'get'

This caused 7 scheduled jobs in our deployment to fail silently.

Solution

Adds a .get() method that:

  • Returns the dataclass attribute if it exists
  • Falls back to the additional dict for extra config values
  • Returns the provided default if key is not found

Changes

  • agent.py: Added get() method to AgentConfig class (lines 317-335)

Backwards Compatibility

Fully backwards compatible. No existing behavior changes. Only adds a new method.

Testing

  • Verified the method returns correct values for existing attributes
  • Verified fallback to additional dict works
  • Verified default value is returned for unknown keys
  • 7 previously failing scheduled jobs now run successfully

AgentConfig is a @DataClass used throughout the framework as a configuration
object. Extensions, skills, and external tools often receive config objects
and expect dict-like .get() access with default values.

Without this method, code that calls config.get('key', default) raises:
  AttributeError: 'AgentConfig' object has no attribute 'get'

This patch adds a .get() method that:
- Returns the dataclass attribute if it exists
- Falls back to the 'additional' dict for extra config values
- Returns the provided default if key is not found

Backwards compatible - no existing behavior changes.
@gdeyoung
Copy link
Copy Markdown
Contributor Author

gdeyoung commented Apr 6, 2026

Closing this PR to resubmit cleanly from a synced fork (v1.7). The fork was 578 commits behind upstream. Will resubmit with a fresh branch.

@gdeyoung gdeyoung closed this Apr 6, 2026
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