FoundationAgents/OpenManus · error · ServerError
Error invoking agent: {e}
Error message
Error invoking agent: {e} What it means
Raised by the A2A agent executor when constructing or invoking the agent fails: any exception from agent_factory() or agent.invoke() (including the NotImplementedError from stream-based misuse, network errors to backing LLMs, missing API keys, or agent timeouts) is wrapped in ServerError(ValueError('Error invoking agent: ...')). The original exception is chained via 'from e'.
Source
Thrown at protocol/a2a/app/agent_executor.py:45
self.agent_factory = agent_factory
async def execute(
self,
context: RequestContext,
event_queue: EventQueue,
) -> None:
error = self._validate_request(context)
if error:
raise ServerError(error=InvalidParamsError())
query = context.get_user_input()
try:
self.agent = await self.agent_factory()
result = await self.agent.invoke(query, context.context_id)
print(f"Final Result ===> {result}")
except Exception as e:
print("Error invoking agent: %s", e)
raise ServerError(error=ValueError(f"Error invoking agent: {e}")) from e
parts = [
Part(
root=TextPart(
text=(
result["content"]
if result["content"]
else "failed to generate response"
)
),
)
]
event_queue.enqueue_event(
completed_task(
context.task_id,
context.context_id,
[new_artifact(parts, f"task_{context.task_id}")],
[context.message],
)View on GitHub (pinned to 52a13f2a57)
Solutions
- Check the chained exception (raise ... from e preserves it) — print e.__cause__ or enable traceback logging to see the root cause.
- Verify the agent's runtime prerequisites: API keys set, network egress allowed, factory callable returns a healthy agent.
- Test the agent directly (await agent.invoke(query, sid)) outside the executor to isolate executor vs agent failure.
- Fix the logging bug: use print(f'Error invoking agent: {e}') or logging.exception(...) so the actual error appears in server logs.
Example fix
# before
except Exception as e:
print("Error invoking agent: %s", e) # literal '%s' in output, cause hidden
raise ServerError(error=ValueError(f"Error invoking agent: {e}")) from e
# after
except Exception as e:
logging.exception("Error invoking agent") # full traceback including __cause__
raise ServerError(error=ValueError(f"Error invoking agent: {e}")) from e Defensive patterns
Strategy: try-catch
Validate before calling
# verify agent prerequisites before serving requests
assert os.environ.get('LLM_API_KEY'), 'missing LLM_API_KEY'
agent = await agent_factory() # fail fast at startup, not per request Try / catch
try:
result = await agent.invoke(query, context.context_id)
except ServerError as e:
root = e.error.message if e.error else str(e)
if root.startswith('Error invoking agent:'):
cause = e.__cause__ or e # original exception is chained
log.error('agent failure: %r', cause)
# surface cause details, do not retry blindly Prevention
- Fail fast: construct the agent via its factory at startup so config/key errors surface before traffic.
- Use logging.exception or f-strings so the chained cause is visible (the shipped print uses %s literally).
- Keep client and server a2a-sdk versions in sync to avoid serialization-shaped invoke failures.
When it happens
Trigger: agent_factory() raising (bad config, missing env vars like API keys, dependency import errors), or agent.invoke() raising mid-run (LLM provider error, tool failure inside Manus, invalid session/context). The printed line uses %s inside print(), which is a formatting bug — the raw '%s' placeholder and exception print literally, so logs look odd.
Common situations: Missing or expired LLM API credentials in the server environment; sandboxed deployments blocking outbound LLM calls; misconfigured agent factory; the underlying agent hitting its own internal error. The poor log line ('Error invoking agent: %s', e) often hides the real cause, forcing developers to debug blind.
Related errors
- Failed to create sandbox: {e}
- Failed to read file: {e}
- Failed to write file: {e}
- Failed to copy file: {e}
- Streaming is not supported by Manus yet.
AI-assisted analysis of FoundationAgents/OpenManus@52a13f2a57 (2026-08-15).
Data as JSON: /api/errors/98eb5d104dea7541.
Report an issue: GitHub.