Repository navigation
The CrewAI Bot is a CrewAI conversational Agent - #2636
lorenzejay wants to merge 12 commits into
Conversation
The CrewAI engine was a one-step Flow that called the model through LiteLLM directly, so no CrewAI Agent ever ran. It now runs CrewAI 1.15.45's conversational Agent session, served by ag-ui-crewai with conversational=True, and keeps OpenBot's contract: - The server's system messages (the Bot's role and tool guidance), which ag-ui-crewai's conversational mode drops, reach the Agent after CrewAI's own system prompt. - OpenBot's tools are handed back to the server: each is a result_as_answer stand-in that ends the turn with the model's own call id, and its phantom backend tool events are suppressed. - Messages keep the ids they arrived with, so the authoritative snapshot doesn't show the thread twice. - An image on the request survives a continuation run. Same harness id, image, port and route; no API change. OpenAI, Anthropic and Google models go through CrewAI's native SDK clients (extras added); LiteLLM stays the fallback. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A live run appends the current user message to the session as a plain dict, and CrewAI appends its base ConversationMessage. Pydantic never sees in-place appends, and CrewAI serializes the state on every step, so every run logged "serialized value may not be as expected". The state's serializer now coerces those entries, leaving the list itself untouched. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ol calls CrewAI's Gemini client failed every run that followed an OpenBot tool, and dropped images: - A tool result now carries the name of the tool it answers, taken from the matching tool call; Gemini refuses an empty function_response name. - Image parts become Gemini's inlineData / fileData parts, the only image parts CrewAI's Gemini client reads. - A replayed tool call carries Google's documented placeholder thought signature, since AG-UI has nowhere to keep the real one between runs. All three apply to Google only: a strict OpenAI-compatible server refuses a name on a tool message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-agent # Conflicts: # CHANGELOG.md
The CrewAI Bot's main.py takes this branch's side; the next commit carries main's Gemini thought signatures (CopilotKit#2397), progress reminders (CopilotKit#2436, CopilotKit#2443) and empty-turn rule (CopilotKit#2449) into it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ain's Gemini and reminder rules The conversational Agent now does what the Bot on main did: - A tool whose name CrewAI changes for the model (`showNote`, `askApproval`, `mcp__...`) is handed back under the server's name. The model calls it by `sanitize_tool_name`, and the hand-back looked it up by the server's name, so the turn answered "Handed to the caller to run." - A handed-back call leaves out the `null`s its own schema did not ask for. CrewAI offers tools in strict mode, so every optional field came back as `null`. - A `developer` message is kept as an instruction and left out of CrewAI's session, whose messages have no such role. It refused the whole run. - An empty `OPENAI_BASE_URL` or `ANTHROPIC_BASE_URL` is unset. The providers' own SDKs took `""` as the address, and every OpenAI run failed with `APIConnectionError`. - The model runs on CrewAI's own client for OpenAI, Anthropic and Google, whatever it is called. CrewAI sent a model it has not heard of (Gemini on the model gateway, `qwen/qwen3-8b`) to LiteLLM, which offered it no tools. - The words the model said in a step that called tools are the reply's content. CrewAI keeps that step with none, so a line on a long job never reached the person. From main: Gemini's thought signature goes out on the handed-back call's `encryptedValue` and back to Gemini, with Google's placeholder only for a call the thread has none for (CopilotKit#2397); the progress reminder after five silent steps (CopilotKit#2436, CopilotKit#2443), added to the latest result where CrewAI would take a note in the person's turn for the request; the empty-turn rule (CopilotKit#2449); `google` as `gemini/`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CHANGELOG takes main's notes for 1.2.6 and adds the CrewAI Bot's entry under Bots.
davidmckayv
left a comment
There was a problem hiding this comment.
Thanks for this, Lorenze. Making the built-in CrewAI Bot a real CrewAI conversational agent is the right direction. The design holds up: tool calls go back to OpenBot under their original names, instructions and history are kept, and it gives the built-in Bot nothing a connected AG-UI Bot can't have. The tests through the real endpoint are good. Three things block it, though.
Blockers
-
Tools with open-ended arguments can only ever be sent
{}(agent-crewai/src/main.py:616). CrewAI offers tools in strict mode, which closes every open-ended object. I ranartifact_createandartifact_patchthrough it with their real schemas. On both OpenAI and Anthropic, an artifact'scontentcomes out as an object that allows no keys, and a patch'svaluecan only be{}or null. The model is forced to follow that schema, so a CrewAI Bot can no longer write an artifact at all. App and MCP tools with free-form maps break the same way. Today's Bot sends the schemas through unchanged. Please keep open-ended objects open, or turn off strict mode for those tools, and add a test with an open-ended schema. -
One email-typed field fails every run (
main.py:616, and nothing catches the error). When a tool marks a fieldformat: email, CrewAI needs a package the image doesn't install, and the run ends inRUN_ERROR. OpenBot's ownmanage_peopletool marks itsemailfield this way, so this hits every Bot that holds it. App tools are cleaned of this on the server, but built-in tools are sent as they are. Tuple-styleitemsarrays crash the same way. Please convert these schemas safely, or install the missing dependency, and add a test for both. -
CrewAI's private internals are used with no version pin (
requirements.txt:34-35). Besides the two adapter patches (main.py:330,main.py:570), the Bot relies on five private CrewAI internals:_conversation_streaming_enabled,_emit_conversation_message_added,_assistant_reply_appended,_standalone_agentand_skip_auto_memory(main.py:968-1033). The requirements set only minimum versions, so the image takes whatever is current when it's built. The PR says 1.15.45, and a fresh install already gets 1.15.47. If one of those names changes, the Bot could post its reply twice, or start writing CrewAI memory, which defaults to OpenAI embeddings. Please pin exact versions so upgrades come through CI.
Smaller things (not blocking)
- When the model calls a tool under a name that doesn't match, the person sees "Handed to the caller to run." as the reply (
main.py:368,main.py:530). - When two tool names collide, the numbered name can pass 64 characters (
main.py:602-606). - System messages from the middle of a thread are moved to the top (
main.py:320). - The global
httpxpatch parses every request body as JSON. - CrewAI prints its Flow console panels on every run, which fills the logs.
docs/agent-frameworks.md:293says "Start from that file", but that file imports OpenBot-only modules.
Before rollout, these need checking live:
- an artifact create and patch on OpenAI and on Anthropic;
- a Bot holding many app (Composio/MCP) tools;
- a tool round trip on Anthropic, on Gemini through the gateway, and on a local OpenAI-compatible server;
- a Responses-only model making a real tool call;
- the image built, with the Model lock workflow run on Anthropic and Google (both were skipped on this head).
No API or database impact. Happy to re-review as soon as the three blockers are in.
…-crewai Review on CopilotKit#2636: - Tools are offered with the caller's own schema and strict mode off, as the Bot on main does. Strict mode closed every open-ended object, so an artifact's content and a patch's value could only be sent {}. Unsupported formats are left out and tuple-style items become one schema. - No Pydantic model is built from a caller's schema, so a format: email field (manage_people) or tuple-style items no longer fails every run. - crewai==1.15.47 and ag-ui-crewai==1.0.0, pinned; a test checks the private parts the Bot relies on are still there. - A call CrewAI matched by its sanitized name is handed back, and a turn that ran a caller's tool never replies with the stand-in's text. - Numbered tool names stay within 64 characters. - System messages from the middle of a thread stay in place. - The httpx hook reads a body only when the chosen model is a Gemini model that checks signatures. - CrewAI's console panels are quiet; errors and the trace link still log. - A Responses-only model (gpt-5.3-codex) moves to the Responses API with OpenAI's current 404 wording. - docs: read main.py as a reference, not a file to start from.
…wai-conversational-agent
…l request's description
|
Thanks David, all three blockers are fixed, and so are the smaller items. Blockers
Smaller things
Before-rollout checks, live with the real schemas, two turns each (call handed back, result sent, answer finished):
The branch also merges main, and CHANGELOG.md is back to main's copy. The note is now under |
davidmckayv
left a comment
There was a problem hiding this comment.
Thanks, Lorenze. Re-reviewed at 2013948. Two of the three blockers are fully resolved, and the third is nearly there.
Resolved
- Open-ended tool schemas. A caller's tools are now offered as written with
strict: False, on Chat Completions, the Responses API, Anthropic and Gemini.test_a_callers_tools_are_offered_as_written_and_not_in_strict_modeand thecaller-schemasloopback check an artifact'scontentand a patch'svaluestay open. format: emailand tuple-styleitems. No Pydantic model is built from a caller's schema any more, formats are stripped and listitemsbecome one schema.manage_peopleand a tuple field are both covered.- Private CrewAI internals.
test_the_parts_of_crewai_and_ag_ui_crewai_this_bot_relies_on_are_therereally works. I renamed each of the five internals in an installed CrewAI, one at a time, and the test failed every time. It passes again once they are restored. All 66 harness tests pass locally on the pinned versions.
Still open
agent-crewai/requirements.txt:13:crewai==1.15.47came out on 2026-11-30, two days ago. We only pin a release once it is at least two weeks old.1.15.41(2026-11-12) is the newest that qualifies, and I ran the full harness suite on it: 66 of 66 pass. Please pincrewai[anthropic,google-genai]==1.15.41.ag-ui-crewai==1.0.0(2026-10-09) is fine as is.- The branch needs
mainmerged in again. It is missing #2814, which fixed the support-window check that fails on every PR without it. - No CI has run on this head yet. It is a fork PR, so the workflows are waiting for a maintainer to approve them. Once the two changes above are pushed, we'll approve the run, and I'll approve and queue the PR when it's green.
…wai-conversational-agent
… old It is the version shared/model-lock.json records for agent-crewai. The harness suite and the live tool round trips pass on it as they did on 1.15.47.
|
Thanks David. Both are in.
Checked on the new head with
Could a maintainer approve the workflows so CI runs on this head? Anthropic and Gemini through the gateway are still the two I can't run live here. I'll open a separate bump once a newer CrewAI release is two weeks old. 1.15.42 to 1.15.46 add fixes this Bot will want: a streamed delta kept when its chunk also carries usage (vLLM), tool names that start with a digit, and vision on Claude 5. |
|
@davidmckayv ready for another review at a9f20e0: |
What this changes
The CrewAI Bot now answers through CrewAI's conversational Agent (
Agent(conversational=True)), served by ag-ui-crewai's conversational mode (add_crewai_flow_fastapi_endpoint(..., conversational=True)). Before, it called the model directly from a one-step CrewAI Flow. The goal is that a standalone conversational CrewAI Agent works as theagent-crewaiengine, with everything the Bot on main does.What the Bot keeps doing. The Bot's role, the whole thread, and OpenBot's tools reach it as before. Replies still arrive whole, not word by word (see Not in this PR).
What the conversational path needed (all in
agent-crewai/src/main.py):developermessages. ag-ui-crewai's conversational path drops every system message of a run. The Bot keeps them for the Agent, each where it was in the thread: the role first, a note from the middle of the thread after the turn it followed. It also keepsdevelopermessages, and leaves them out of CrewAI's session, whose messages have no such role. Before, a run with one failed with a ValidationError.sanitize_tool_name(name), soshowBarChartreaches it asshow_bar_chart. The Bot names the tool that way and hands the call back asshowBarChart;askApprovalandmcp__…tools work the same way. Numbered names for tools that collide stay within 64 characters. A turn whose call can't be matched to a tool fails rather than reply with the stand-in's text.contentor a patch'svaluecould only be{}. Aformatother than a date or time is left out, and tuple-styleitemsbecome one schema. No Pydantic model is built from the schema, so aformat: emailfield (manage_people) or tuple-styleitemsno longer fail the run.nulls a tool's own schema did not allow are taken out of the handed-back call.openai/<model>CrewAI sends a model it has not heard of (Gemini on the model gateway,qwen/qwen3-8bon a local server) to LiteLLM, which offered it no tools. An emptyOPENAI_BASE_URLorANTHROPIC_BASE_URL, as Compose writes for a plain key, is treated as unset. A model OpenAI serves only on the Responses API (gpt-5.3-codex) is moved there: CrewAI does this only for an older wording of OpenAI's 404. Any other provider still goes through LiteLLM.crewai==1.15.41(the versionshared/model-lock.jsonrecords) andag-ui-crewai==1.0.0. The Bot relies on parts of both that neither publishes; a test checks each is still there, so an upgrade comes through CI.encryptedValueand back to Gemini (Gemini 3 Bots finish a tool call on ADK, AG2, CrewAI, Langroid, Mastra and Strands #2397). It is read off the answer at the HTTP layer (only when the chosen model is a Gemini model that checks signatures), because CrewAI's OpenAI client dropsextra_content, and taken fromraw_tool_call_partson CrewAI's own Gemini client.googleasgemini/.docs/agent-frameworks.mdlists what a conversational CrewAI Agent needs, for anyone building their own, and points atmain.pyas a reference rather than a file to copy.Not in this PR.
llm_stream_chunkevents, so replies arrive whole. That fix belongs in ag-ui-crewai.crewai_prepare_inputsandis_backend_tool_event, and CrewAI's tool-schema conversion and Responses-API check. Each is worth fixing upstream (a per-toolstrictflag in CrewAI; the newer 404 wording), after which the patches can go.extra_contenton tool calls.Where it runs
Boundary and audit
API and database
api/, no app's requests, no database change and norelease-policy.json.Changelog
Bots.
Agent(conversational=True)), served by ag-ui-crewai's conversational mode. Before, it called the model directly from a one-step CrewAI Flow. The Bot's role, the whole thread and OpenBot's tools reach it as they did, and its replies still arrive whole rather than word by word. CrewAI now calls OpenAI, Anthropic and Google models through their own SDKs, and any other model through LiteLLM as before.Proof
python -m pytest agent-crewai/tests, as CI runs it (fresh venv,pip installof both requirements files,crewai 1.15.41): 66 passed. The same tests against this branch before the review fixes: 18 failed, including the run with OpenBot's real tool schemas, which ended inRUN_ERROR(ImportError, theemailfield).Live, this branch's Bot on
crewai 1.15.41with OpenBot's realartifact_create,artifact_patchandmanage_peopleschemas, two turns each (the call handed back, its result sent back, the answer finished):manage_peoplegpt-5.5content: {"markdown": …}value: 42gpt-6-astragpt-5.3-codexgemma4on OllamaBefore, on
gpt-5.5: every run failed whilemanage_peoplewas offered; with only the artifact tools, the model sentcontent: {}andvalue: {}.In the app, with
main's server and the image built from this branch (crewai 1.15.41):artifact_createmade a sheet (v1, South 200), thenartifact_patchchanged one cell (v2, South 275, note "Updated South revenue"). The audit trail hasartifact.createdand thenartifact.editedwith"via": "patch", both by the CrewAI Bot.In the app, earlier, with the image built from this branch: plain reply, a choice card handed back and continued, a server-run computer command, a Firecrawl MCP call, and later turns answered from those results; the thread stored and reloaded whole.
Not run live: Anthropic and Gemini (no keys here). Their schema handling is covered by unit tests on CrewAI's own Anthropic and Gemini clients. The Model lock workflow is skipped for a fork's pull request.