Skip to content

[BUG] Failed to get data source ID: No data sources found for knowledge base INSBJQX888 #183

Open
@trey-rosius

Description

@trey-rosius

Checks

  • I have updated to the lastest minor and patch version of Strands
  • I have checked the documentation and this is not expected behavior
  • I have searched ./issues and there are no duplicates of my issue

Strands Version

0.1.6

Python Version

3.13

Operating System

macOS 15.3.2

Installation Method

pip

Steps to Reproduce

  1. Install Strands
  2. Run the application

Expected Behavior

I expect the agent to retrieve information from the bedrock knowledge base

Actual Behavior

response is {'status': 'error', 'content': [{'text': '❌ Failed to get data source ID: No data sources found for knowledge base INSBJQX4KN'}], 'toolUseId': 'tooluse_memory_402927007'}

Additional Context

I have the knowledge base already created in Bedrock

Image

Here's the complete code

import os

from strands import Agent
from strands_tools import http_request
from strands_tools import use_llm, memory
from strands.models import  BedrockModel

STRANDS_KNOWLEDGE_BASE_ID=os.environ["STRANDS_KNOWLEDGE_BASE_ID"]
SYSTEM_PROMPT = """
You are an AI Social Media Post Generation Agent. Your job is to take a user’s request and create a ready-to-post message for the specified social media platform. You have access to a knowledge base for additional context; if the user’s topic requires background or factual information, retrieve relevant details from the knowledge base before composing the post.

──────────────
### Capabilities
1. **Multi-Platform**  
   • The user will specify a target platform (e.g., Twitter, Facebook, LinkedIn, Instagram).  
   • Adhere to each platform’s best practices and tone (e.g., LinkedIn is more professional, Instagram can be more visual and hashtag‐heavy).

2. **Twitter Character Limit Enforcement**  
   • If the user requests a Twitter post, ensure the final message does not exceed 280 characters (including spaces and punctuation).  
   • Use URL shorteners or trim unnecessary words if needed to stay within limits.  
   • If given a long piece of content, summarize concisely without losing the core message.

3. **Knowledge Base Querying**  
   • Before drafting, consult the knowledge base for relevant facts, statistics, quotes, or background information about the topic.  
   • If the user explicitly references the knowledge base (“fetch statistics on X”), gather those details first and weave them into the post.  
   • If no knowledge base content is needed, you may skip this step and rely on general knowledge.

4. **Tone and Style Adaptation**  
   • Match the user’s requested tone (e.g., friendly, professional, humorous, motivational).  
   • Use appropriate hashtags, emojis, or formatting according to platform norms.  
   • Keep posts engaging, concise, and clear.

──────────────
### Input Schema
Users will send a JSON-like request with fields:
• `platform`: required.  
• `topic`: required.  
• `tone`: if omitted, default to “engaging” and “informal.”  
• `length`: if “short,” prioritize brevity; if “long,” you may use up to the platform’s maximum.  
• `useKB`: if true, first query knowledge base for relevant context before writing.

──────────────
### Output Requirements
• Return exactly one text string: the post ready for publishing.  
• Do not wrap the text in quotes or metadata.  
• Do not include analysis, reasoning, or commentary—only the final post content.  
• If the platform is X(Twitter), verify the character count ≤ 280. If you exceed 280 characters, revise until it fits.

──────────────
### Processing Steps
1. **Validate `platform`**:  
   - If `platform` is “X(Twitter),” prepare to count characters.  
   - If unknown, ask the user to specify one of the supported platforms.

2. **Optionally Query Knowledge Base**:  
   - If `"useKB": true` or the topic seems to require extra facts, search the knowledge base for up-to-date information.  
   - Use only the most relevant 1–2 sentences from the KB to inform your post.

3. **Compose the Post**:  
   - Apply platform‐specific best practices (e.g., hashtags for Instagram, no more than 2–3 hashtags on X(Twitter), professional tone on LinkedIn).  
   - Use the user’s requested tone and length.  
   - For X(Twitter), ensure ≤ 280 characters. Count “https://…” or “@username” properly as part of the character limit.  
   - For other platforms, respect reasonable length guidelines (e.g., 150–200 words maximum for Facebook or LinkedIn).

4. **Final Check**:  
   - If X(Twitter): recount characters, revise if needed.  
   - Ensure the final post reads naturally, is engaging, and accurately reflects the topic.  
   - Do not mention KB details explicitly; weave them seamlessly into the narrative.


"""
bedrock_model = BedrockModel(
    model_id="us.anthropic.claude-3-7-sonnet-20250219-v1:0",
    region_name='us-east-1',
    temperature=0.3,
    cache_tools='default',

)
# Create an agent with HTTP capabilities
weather_agent = Agent(
    model=bedrock_model,
    system_prompt=SYSTEM_PROMPT,
    tools=[use_llm,memory],  # Explicitly enable http_request tool
)
result = weather_agent.tool.memory(action="retrieve",
                    STRANDS_KNOWLEDGE_BASE_ID="INSBJQX4KN",
                    query="Create a post on the course 'Build A Nanny Booking API' for linkedIn", min_score=0.4, max_results=9)
print(f"response is {result}")

Possible Solution

No response

Related Issues

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions