Skip to content

feat(memory): Wire inject_memories through runtime AgentDefaults #3016

@hamza-jeddad

Description

@hamza-jeddad

Background

Sub-issue of #3011. Connect the config fields (from the config sub-issue) to the builtin (from the scaffolding sub-issue) so the runtime actually activates inject_memories for agents that opt in.

Scope

Wire the new AgentConfig fields through the existing builtins/runtime plumbing:

AgentConfig (YAML)
   │
   ▼
ApplyAgentDefaults  → builtins.AgentDefaults
   │
   ▼
buildHooksExecutors → registers inject_memories handler when enabled

Implementation Checklist

  • pkg/agent/agent.go — add accessors:
    • InjectMemories() bool
    • MaxInjectMemories() int
    • InjectMemoriesStrategy() string
  • pkg/runtime/hooks.goApplyAgentDefaults (or equivalent) maps AgentConfig fields to builtins.AgentDefaults
  • pkg/runtime/hooks.gobuildHooksExecutors registers the inject_memories turn_start handler when AgentDefaults.InjectMemories == true and a memory toolset is bound to the agent
  • Populate hooks.Input.LastUserMessage in executeTurnStartHooks (also tracked in feat(memory): Design and implement inject_memories retrieval strategy #3013) — required for the retrieval pipeline to see the user's prompt
  • Unit tests for wiring: config in → handler registered (or not) → executor list contains inject_memories (or does not)

Acceptance Criteria

  • An agent with inject_memories: true and a memory toolset gets the handler registered in its turn_start executors
  • An agent with inject_memories: true but no memory toolset logs a warning and does not register the handler (graceful degradation)
  • An agent with inject_memories: false (or unset) has zero behavioural change
  • Input.LastUserMessage is populated for all turn_start hooks (mirrors executeStopHooks pattern)
  • No regressions in existing turn_start builtin ordering

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/agentFor work that has to do with the general agent loop/agentic features of the apparea/configFor configuration parsing, YAML, environment variablesarea/ragFor work/issues that have to do with the RAG features

    Type

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions