Skip to content

How to format the content generated from AWS Bedrock agent?

0

I am using Bedrock AI Agent with a knowledge base (S3) and I am using "anthropic.claude-3-5-sonnet-20241022-v2:0" as the model in agent. Everything is working fine but the response which agent returns is in a paragraph form without proper formatting.

How can I pass the instructions to the model so that it formats the response ? I tried different instructions for the Agent but still it returns a paragraph. I am not sure if the Agent instruction is the place to it.

Below Agent instruction (and similar) have no effect on the response formatting. Doing this on bedrock agent test console.

You are a helpful support agent for HorizonIQ that answers questions from users in simple language.

When providing responses:
- Always use double line breaks between sections
- Place each list item on its own line with proper spacing
- Format step-by-step instructions with clear numbering and spacing
- Use clear paragraph breaks for different topics
- Keep formatting consistent throughout the response

For technical instructions:
1. Present prerequisites clearly on separate lines
2. Number steps sequentially with proper spacing
3. Separate procedure steps from notes and warnings
4. Include examples when relevant

Base your responses on the provided knowledge base and maintain this formatting structure in all responses.

If you need clarification, ask specific questions rather than stating you don't know the answer.

asked 2 years ago1.3K views

1 Answer
2

To improve the formatting of Claude 3 Sonnet's responses in a Bedrock Agent, you can try these approaches:

In the Agent Knowledge Base Configuration:

  • Bullet points for lists
  • Headers with ## for sections
  • Line breaks between paragraphs
  • Code blocks with ``` for technical content
  • Tables when comparing data

Key Points:

Claude 3 Sonnet generally responds well to explicit formatting requests
Include formatting instructions in the actual question/prompt
Test different instruction placements to see what works best
Consider using markdown syntax in your instructions
Be specific about the desired format

Example Prompt:

Format your response with clear headers, bullet points for key information, and code blocks for technical details: [Your question here]

AWS

answered 2 years ago

EXPERT

reviewed 2 years ago

  • doesn't work even after updating the agent knowledge base config.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.