Skip to content

Amazon Bedrock AgentCore Provider Integration#44

Open
nabiladem wants to merge 8 commits intowalidabualafia:mainfrom
nabiladem:amazon-bedrock-agentcore
Open

Amazon Bedrock AgentCore Provider Integration#44
nabiladem wants to merge 8 commits intowalidabualafia:mainfrom
nabiladem:amazon-bedrock-agentcore

Conversation

@nabiladem
Copy link
Copy Markdown

Closes #5

Amazon Bedrock AgentCore Provider

Description

This PR introduces a new provider for Amazon Bedrock Agents, allowing CaretForge to invoke agents directly via the AWS SDK. This enables users to utilize custom Bedrock Agents (orchestrated with Lambda, Knowledge Bases, etc.) as backend coding assistants.

Key Changes

  • New Provider: Implemented [AwsBedrockAgentCoreProvider (cci:2://file:///Users/nabil/Downloads/caretforge/src/providers/awsBedrockAgentCore.ts:32:0-194:1) in src/providers/awsBedrockAgentCore.ts using the @aws-sdk/client-bedrock-agent-runtime.
  • Configuration: Added awsBedrockAgentCore schema to src/config/schema.ts, supporting standard AWS authentication methods (Profile, Access Keys, Environment Variables).
  • CLI Integration: Registered the new provider in src/cli/shared.ts for both interactive chat and one-shot tasks.
  • Documentation: Updated README.md and docs/reference/configuration.md with setup instructions and credential resolution details.
  • Testing: Added comprehensive unit tests in test/awsBedrockAgentCore.test.ts covering both streaming and non-streaming responses.

Testing

Ran the full test suite (npm test), confirming all tests pass:

  • AwsBedrockAgentCoreProvider tests passed (5/5).
  • Verified integration with existing providers (resolved merge conflicts with azure-responses).

Configuration Example

Users can now configure an AWS Bedrock Agent in ~/.config/caretforge/config.json:

{
  "defaultProvider": "aws-bedrock-agent-core",
  "providers": {
    "awsBedrockAgentCore": {
      "region": "us-east-1",
      "agentRuntimeArn": "arn:aws:bedrock:us-east-1:123456789012:agent-alias/AGENT_ID/ALIAS_ID",
      "profile": "default"
    }
  }
}

Copy link
Copy Markdown
Owner

@walidabualafia walidabualafia left a comment

Choose a reason for hiding this comment

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

Review: Amazon Bedrock AgentCore Provider Integration

Hi @nabiladem. Thanks for the thorough implementation — the provider structure, tests, and documentation are well done overall. However, there are a few issues that need to be addressed before this can be merged.


Blockers

1. Formatting failures (pnpm format:check fails)

Three files do not pass the Prettier format check:

  • docs/reference/configuration.md
  • src/providers/awsBedrockAgentCore.ts
  • test/awsBedrockAgentCore.test.ts

All quality gates must pass before merge. Running pnpm format should fix these.

2. Documentation regression — existing env vars removed

The environment variables table in docs/getting-started/configuration.md accidentally dropped two existing rows when it was reformatted:

| `CARETFORGE_AGENT_ENDPOINT`   | `providers.azureAgents.endpoint`  |
| `CARETFORGE_AGENT_ID`         | `providers.azureAgents.agentId`   |

These env vars are still used in src/config/index.ts and still documented in docs/reference/environment.md. Please restore them.


Strongly Recommended

3. Global process.env.AWS_PROFILE mutation

In src/providers/awsBedrockAgentCore.ts line 65:

process.env.AWS_PROFILE = config.profile;

This mutates the global process environment, which could affect other providers or SDK consumers in the same process. Consider using fromIni({ profile }) from @aws-sdk/credential-provider-ini instead, which keeps the profile selection isolated and side-effect free.

4. Session ID generated per-call breaks multi-turn chat

prepareRequest generates a new sessionId (via Date.now()) on every call. Since the agent loop in src/core/agent.ts calls the provider once per iteration, this means:

  • In caretforge chat, each user message starts a brand-new Bedrock session with no memory of prior turns.
  • Combined with only sending messages[messages.length - 1], the Bedrock Agent has zero context about the conversation.

This makes caretforge chat behave as a series of independent one-shot calls. The session ID should be generated once (e.g. in the constructor or as a lazily-initialized instance field) and reused across calls within the same provider instance.

5. Duplicate AwsBedrockAgentCoreConfig type

Both src/providers/awsBedrockAgentCore.ts (lines 22–29) and src/config/schema.ts (line 79) export an AwsBedrockAgentCoreConfig type. The provider file should import the Zod-inferred type from schema.ts instead of defining its own interface, to prevent future drift between the two.


Minor

6. Unrelated .gitignore change

Adding pnpm-workspace.yaml to .gitignore is unrelated to this PR. Per the contribution guidelines, PRs should not bundle unrelated changes. Please move this to a separate commit or PR.


What looks good

  • Provider implementation follows the existing Provider interface correctly and is consistent with other providers.
  • Config schema, CLI integration (shared.ts), and doctor checks are well-structured.
  • Tests are comprehensive (5 tests covering non-streaming, streaming, client config, model listing, and error handling).
  • New docs/guide/aws-setup.md guide is thorough and well-written.
  • No secrets or sensitive data found in the diff.
  • saveConfig correctly strips accessKeyId, secretAccessKey, and sessionToken.

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.

Add AWS Bedrock AgentCore provider

2 participants