# Base64 String Gets Altered During Crew Execution

**URL:** <https://community.crewai.com/t/base64-string-gets-altered-during-crew-execution/5076>\
**Category:** General\
**Created:** [April 1, 2025, 7:08am UTC](https://community.crewai.com/t/base64-string-gets-altered-during-crew-execution/5076 "2025-04-01T07:08:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![liyan2dmn](https://avatars.discourse-cdn.com/v4/letter/l/7cd45c/32.png) [@liyan2dmn](https://community.crewai.com/u/liyan2dmn)\
**Post date:** [April 1, 2025, 7:08am UTC](https://community.crewai.com/t/base64-string-gets-altered-during-crew-execution/5076/1 "2025-04-01T07:08:21Z")

</div>

Hey everyone,

We’ve developed an agent and a task to extract information from a base64-encoded image string. The extraction is handled by a custom tool that decodes the base64 string, converts it into an image, and processes it using a vision model.

However, during Crew execution, we’ve noticed that the base64 string gets altered somehow, making it unreadable by our custom tool. This results in extraction failures.

We’ve tested multiple approaches, including trying different versions of the crewai library (including the latest), but the issue persists.

Here’s a snippet of our implementation:

@tool(“callback\_extract\_expense\_details\_fn”)  
def callback\_extract\_expense\_details\_fn(base64\_image: str) → dict:

```
   try:
    image_data = base64.b64decode(base64_image)  
    image = Image.open(io.BytesIO(image_data))  
    prompt = """Identify and extract only the following from the image:  
                Merchant Name, Invoice Number, Invoice Date, and Charges for the Period."""

    vision_model = genai.GenerativeModel("gemini-1.5-flash")  
    response = vision_model.generate_content([prompt, image])  

    return response.text  
except Exception as e:
    print(f"Error extracting details: {e}")
    return None

```

The Crew setup involves an agent assigned to process the base64-encoded image string:  
image\_data\_extractor = Agent(  
role=“Image Data Extractor”,  
goal=“Extract expense details from an image.”,  
tools=[callback\_extract\_expense\_details\_fn],  
verbose=True,  
llm=llm  
)

extract\_task = Task(  
description=“Extract expense details from a base64 encoded image”,  
agent=image\_data\_extractor,  
input=base64\_encoded\_file,  
expected\_output=“dict containing extracted details or error”  
)

crew = Crew(  
agents=[image\_data\_extractor],  
tasks=[extract\_task],  
verbose=True,  
process=Process.sequential  
)

crew\_output = crew.kickoff()

Issue Faced:  
The base64 string changes when passed through the Crew execution flow.

The modified string becomes unreadable by our custom tool.

Questions:

1. Could CrewAI be modifying the string during task execution?
2. Is there a best practice for passing binary data (base64) between agents without corruption?

Would really appreciate any insights or suggestions.

Thanks!

---

<div class="post-metadata">

**Author:** ![zinyando](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/zinyando/32/4435_2.png) [@zinyando](https://community.crewai.com/u/zinyando)\
**Post date:** [April 3, 2025, 4:57pm UTC](https://community.crewai.com/t/base64-string-gets-altered-during-crew-execution/5076/2 "2025-04-03T16:57:22Z")

</div>

What do you mean when you say altered? Have you tried to print the string when it’s called in the tool comparing with the original you passed in.

How are you passing the base64 string in? The more details you share the better

---

<div class="post-metadata">

**Author:** ![liyan2dmn](https://avatars.discourse-cdn.com/v4/letter/l/7cd45c/32.png) [@liyan2dmn](https://community.crewai.com/u/liyan2dmn)\
**Post date:** [April 16, 2025, 8:42am UTC](https://community.crewai.com/t/base64-string-gets-altered-during-crew-execution/5076/3 "2025-04-16T08:42:47Z")

</div>

Hi @zinyando , Thanks for commenting on my issue. I’ve printed the input base64 string. Also set verbose=True. During the crew execution it print the prompt I observed that input base64 string and the value available in the prompts are different. Also when it decoding gives the error that base64 is unable to decode.

Do you have any suggestion to check this issue further?

Thanks,

---

<div class="post-metadata">

**Author:** ![maxmoura](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/maxmoura/32/4206_2.png) [@maxmoura](https://community.crewai.com/u/maxmoura)\
**Post date:** [April 16, 2025, 11:53am UTC](https://community.crewai.com/t/base64-string-gets-altered-during-crew-execution/5076/4 "2025-04-16T11:53:09Z")

</div>

@liyan2dmn, if you’re trying to build a multimodal agent (especially one that needs to handle images), you should probably start by checking out CrewAI’s built-in capabilities for this. Take a look at the examples in “[Using Multimodal Agents](https://docs.crewai.com/how-to/multimodal-agents)” in the official docs, and then you can tailor it to your specific needs from there.

---

<div class="post-metadata">

**Author:** ![dkapsalis](https://avatars.discourse-cdn.com/v4/letter/d/f05b48/32.png) [@dkapsalis](https://community.crewai.com/u/dkapsalis)\
**Post date:** [April 16, 2025, 8:10pm UTC](https://community.crewai.com/t/base64-string-gets-altered-during-crew-execution/5076/5 "2025-04-16T20:10:59Z")

</div>

Can you provide more details on what changes occur on the Base64 string?  
Is the string truncated? Is it completely different?

---

<div class="post-metadata">

**Author:** ![liyan2dmn](https://avatars.discourse-cdn.com/v4/letter/l/7cd45c/32.png) [@liyan2dmn](https://community.crewai.com/u/liyan2dmn)\
**Post date:** [June 11, 2025, 5:04am UTC](https://community.crewai.com/t/base64-string-gets-altered-during-crew-execution/5076/6 "2025-06-11T05:04:26Z")

</div>

Hi @dkapsalis, It is not truncated, it different from original one.
