FoundationAgents/MetaGPT · error · ValueError
{function_name} not found
Error message
{function_name} not found What it means
SkillAction.find_and_call_function dispatches a skill by importing metagpt.learn and getattr-ing the function name on it. If the module import fails or the attribute does not exist (the skill was never registered/exported in metagpt/learn/__init__.py), it logs 'X not found' and re-raises as ValueError. Only skills explicitly exported by metagpt.learn (google_search, text_to_speech, text_to_image, text_to_embedding, skill_loader helpers) are callable.
Source
Thrown at metagpt/actions/skill_action.py:113
try:
rsp = await self.find_and_call_function(self.skill.name, args=self.args, **options)
self.rsp = Message(content=rsp, role="assistant", cause_by=self)
except Exception as e:
logger.exception(f"{e}, traceback:{traceback.format_exc()}")
self.rsp = Message(content=f"Error: {e}", role="assistant", cause_by=self)
return self.rsp
@staticmethod
async def find_and_call_function(function_name, args, **kwargs) -> str:
try:
module = importlib.import_module("metagpt.learn")
function = getattr(module, function_name)
# Invoke function and return result
result = await function(**args, **kwargs)
return result
except (ModuleNotFoundError, AttributeError):
logger.error(f"{function_name} not found")
raise ValueError(f"{function_name} not found")
View on GitHub (pinned to 11cdf466d0)
Solutions
- Verify the function exists: run python -c "import metagpt.learn as m; print(hasattr(m, 'NAME'))".
- Add your custom skill function to metagpt/learn/__init__.py (or monkeypatch/extend it) so getattr succeeds.
- Fix spelling/case of skill.name to exactly match the exported python function name.
Example fix
# before # my_skill defined only in my_pkg/skills.py -> ValueError: my_skill not found # after # metagpt/learn/__init__.py from my_pkg.skills import my_skill # now getattr(metagpt.learn, 'my_skill') works
Defensive patterns
Strategy: try-catch
Validate before calling
import metagpt.learn as ml
assert hasattr(ml, skill.name), f"skill '{skill.name}' is not exported by metagpt.learn" Type guard
import metagpt.learn as _ml
def skill_exists(name: str) -> bool:
return hasattr(_ml, name) Try / catch
try:
result = await SkillAction.find_and_call_function(name, args)
except ValueError as e:
if 'not found' in str(e):
logger.warning('skill missing, falling back')
result = await fallback_handler(name, args) Prevention
- Register custom skills in metagpt.learn's namespace before use.
- Validate skill names against metagpt.learn exports at startup.
- Pin skill names from a config checklist rather than free text.
When it happens
Trigger: SkillAction.run with skill.name set to a function not exported from metagpt.learn (e.g. 'my_custom_skill' or a misspelled name), or when a custom skill exists in a plugin package but was not added to metagpt.learn's namespace.
Common situations: Writing new skills in your own module but expecting SkillAction to find them; name mismatches between the skill yaml/registry name and the python function name; version changes that rename or remove a learned skill.
Related errors
- Trying to instantiate {class_full_name}, which has not yet b
- api_name: {api_name} not found
- Creator not registered for key: {key}
- Unknown config: `{type(key)}`, {key}
AI-assisted analysis of FoundationAgents/MetaGPT@11cdf466d0 (2026-08-14).
Data as JSON: /api/errors/d0e0433e61d6edc5.
Report an issue: GitHub.