Skip to content

enhance(bedrockagentcore_memory_strategy): add reflection_configuration for EPISODIC type#48758

Open
sanyamk23 wants to merge 2 commits into
hashicorp:mainfrom
sanyamk23:feat/bedrockagentcore-memory-strategy-reflection-config
Open

enhance(bedrockagentcore_memory_strategy): add reflection_configuration for EPISODIC type#48758
sanyamk23 wants to merge 2 commits into
hashicorp:mainfrom
sanyamk23:feat/bedrockagentcore-memory-strategy-reflection-config

Conversation

@sanyamk23

Copy link
Copy Markdown

Description

Adds support for configuring reflection behavior in both built-in EPISODIC and CUSTOM EPISODIC_OVERRIDE memory strategies.

What this PR does

The aws_bedrockagentcore_memory_strategy resource previously only exposed the type = "EPISODIC" option without allowing users to configure the reflection step — the cross-episode insight generation that produces "patterns, successful strategies, failure modes, and lessons learned."

This PR adds two new optional blocks:

1. reflection_configuration block (built-in EPISODIC)

Allows users to customize where reflection records are stored via namespace_templates. When omitted, defaults to using the episodic namespaces (preserving existing behavior).

resource "aws_bedrockagentcore_memory_strategy" "episodic" {
  name       = "episodic-strategy"
  memory_id  = aws_bedrockagentcore_memory.example.id
  type       = "EPISODIC"
  namespaces = ["/strategies/{memoryStrategyId}/actors/{actorId}/sessions/{sessionId}"]

  reflection_configuration {
    namespace_templates = ["/strategies/{memoryStrategyId}/actors/{actorId}/reflections"]
  }
}

2. reflection block inside configuration (CUSTOM EPISODIC_OVERRIDE)

Allows full customization of the reflection step including append_to_prompt, model_id, and namespace_templates.

resource "aws_bedrockagentcore_memory_strategy" "custom_episodic" {
  name       = "custom-episodic-strategy"
  memory_id  = aws_bedrockagentcore_memory.example.id
  type       = "CUSTOM"
  namespaces = ["/strategies/{memoryStrategyId}/actors/{actorId}/sessions/{sessionId}"]

  configuration {
    type = "EPISODIC_OVERRIDE"

    consolidation {
      append_to_prompt = "Consolidate episodic memories into coherent narratives"
      model_id         = "anthropic.claude-3-sonnet-20240229-v1:0"
    }

    extraction {
      append_to_prompt = "Extract key events and episodes from interactions"
      model_id         = "anthropic.claude-3-haiku-20240307-v1:0"
    }

    reflection {
      append_to_prompt    = "Identify successful patterns and recurring failure modes across episodes"
      model_id            = "anthropic.claude-3-sonnet-20240229-v1:0"
      namespace_templates = ["/strategies/{memoryStrategyId}/actors/{actorId}/reflections"]
    }
  }
}

Changes

  • Schema: Added reflection_configuration ListNestedBlock (EPISODIC only), reflection ListNestedBlock inside configuration (EPISODIC_OVERRIDE only)
  • Model: Added reflectionConfigurationModel and reflectionOverrideModel types
  • Expand: Updated expandToMemoryStrategyInput to use user-provided reflection config; updated expandToModifyStrategyConfiguration to handle reflection in EPISODIC_OVERRIDE
  • Flatten: Added reflection flattening in customConfigurationModel.Flatten for CUSTOM types; added manual reflection flattening in Read/Create for built-in EPISODIC
  • Validation: reflection_configuration only allowed with EPISODIC; reflection only allowed inside CUSTOM EPISODIC_OVERRIDE
  • Documentation: Added examples for both use cases, documented all new arguments

Affected Resource(s)

  • aws_bedrockagentcore_memory_strategy

References

@sanyamk23 sanyamk23 requested a review from a team as a code owner July 2, 2026 18:24
@dosubot dosubot Bot added the enhancement Requests to existing resources that expand the functionality or scope. label Jul 2, 2026
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Community Guidelines

This comment is added to every new Pull Request to provide quick reference to how the Terraform AWS Provider is maintained. Please review the information below, and thank you for contributing to the community that keeps the provider thriving! 🚀

Voting for Prioritization

  • Please vote on this Pull Request by adding a 👍 reaction to the original post to help the community and maintainers prioritize it.
  • Please see our prioritization guide for additional information on how the maintainers handle prioritization.
  • Please do not leave +1 or other comments that do not add relevant new information or questions; they generate extra noise for others following the Pull Request and do not help prioritize the request.

Pull Request Authors

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

✅ Thank you for correcting the previously detected issues! The maintainers appreciate your efforts to make the review process as smooth as possible.

@github-actions github-actions Bot added needs-triage Waiting for first response or review from a maintainer. documentation Introduces or discusses updates to documentation. service/bedrockagentcore Issues and PRs that pertain to the bedrockagentcore service. size/L Managed by automation to categorize the size of a PR. labels Jul 2, 2026
…on for EPISODIC type

Adds support for configuring reflection behavior in both built-in EPISODIC
and CUSTOM EPISODIC_OVERRIDE memory strategies.

For built-in EPISODIC strategies, a new optional reflection_configuration
block allows users to customize where cross-episode reflection records are
stored via namespace_templates.

For CUSTOM strategies with EPISODIC_OVERRIDE type, a new optional
reflection block inside configuration allows full customization of
the reflection step including append_to_prompt, model_id, and
namespace_templates.

Closes hashicorp#47938
@sanyamk23 sanyamk23 force-pushed the feat/bedrockagentcore-memory-strategy-reflection-config branch from e60a424 to c0652cd Compare July 2, 2026 18:27

@sanyamk23 sanyamk23 left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

@ewbankkit ewbankkit removed the needs-triage Waiting for first response or review from a maintainer. label Jul 9, 2026
@aidandaly24

Copy link
Copy Markdown

Heads up that the current head (c0652cd) doesn't compile, so that needs sorting before the rest can be tested. Running go build / gofmt -e on internal/service/bedrockagentcore/memory_strategy.go there are four issues, two syntax and two undefined symbols.

  1. Extra closing brace in ValidateConfig:
internal/service/bedrockagentcore/memory_strategy.go:301:1: expected declaration, found '}'

The else branch closes at line 299 and then there are two } (lines 300 and 301), one too many for the function body. Dropping the stray } at line 300 fixes it.

  1. The new if t.Reflection != nil is mis-nested inside if t.Extraction != nil in customConfigurationModel.Flatten:
internal/service/bedrockagentcore/memory_strategy.go:885:2: expected '}', found 'default'

The if t.Reflection != nil (line 864) opens while still inside the if t.Extraction != nil block (line 850), and the resulting extra } at line 884 closes switch t := v.(type) before its default: case (line 885). The fix is to close the extraction block before the reflection handling and make if t.Reflection a sibling of if t.Extraction. Worth calling out that this isn't only the brace, as written reflection only gets read back when the API returns a non-nil Extraction, so making it a sibling fixes that too.

  1. The reflection_configuration block is in the Attributes map instead of Blocks. At line 91 reflection_configuration: schema.ListNestedBlock{...} is added to the top-level Attributes map, but ListNestedBlock is a Block not an Attribute so it won't type-check (ListNestedBlock does not implement schema.Attribute). The nested reflection block at line 166 is under the Blocks map correctly, this top-level one just needs to move to the resource's Blocks map. This one is masked until 1 and 2 are fixed since the build stops at the syntax errors first.

  2. fwtypes.ListOfStringValueFrom doesn't exist. Both the Create flatten (line 366) and Read flatten (line 428) call it, but there's no ListOfStringValueFrom in internal/framework/types. The existing helper for []string to ListOfString is fwflex.FlattenFrameworkStringValueListOfString (internal/framework/flex/list.go:39), which returns a single value with no diags, so both call sites become:

rc.NamespaceTemplates = fwflex.FlattenFrameworkStringValueListOfString(ctx, episodicReflection.Value.NamespaceTemplates)

Once those are in the package should build and the acceptance tests can actually run the new paths. Happy to test the reflection round-trip against real AWS once it compiles. Thanks!

@sanyamk23 sanyamk23 force-pushed the feat/bedrockagentcore-memory-strategy-reflection-config branch from d5979fc to aa310fb Compare July 10, 2026 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Introduces or discusses updates to documentation. enhancement Requests to existing resources that expand the functionality or scope. service/bedrockagentcore Issues and PRs that pertain to the bedrockagentcore service. size/L Managed by automation to categorize the size of a PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement]: aws_bedrockagentcore_memory_strategy missing reflection configuration for EPISODIC type

3 participants