Amazon Bedrock AgentCore Provider Integration#44
Amazon Bedrock AgentCore Provider Integration#44nabiladem wants to merge 8 commits intowalidabualafia:mainfrom
Conversation
There was a problem hiding this comment.
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.mdsrc/providers/awsBedrockAgentCore.tstest/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
Providerinterface 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.mdguide is thorough and well-written. - No secrets or sensitive data found in the diff.
saveConfigcorrectly stripsaccessKeyId,secretAccessKey, andsessionToken.
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
@aws-sdk/client-bedrock-agent-runtime.awsBedrockAgentCoreschema to src/config/schema.ts, supporting standard AWS authentication methods (Profile, Access Keys, Environment Variables).Testing
Ran the full test suite (
npm test), confirming all tests pass: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" } } }