{"record":{"id":"a3ce31d1b53ee7ae","repo":"langchain-ai/deepagents","slug":"project-is-only-valid-for-the-langsmith-service-n","errorCode":null,"errorMessage":"project is only valid for the langsmith service, not {provider!r}","messagePattern":"project is only valid for the langsmith service, not (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/auth_store.py","lineNumber":499,"sourceCode":"        \"type\": \"api_key\",\n        \"key\": cleaned,\n        \"added_at\": datetime.now(tz=UTC).isoformat(timespec=\"seconds\"),\n    }\n    cleaned_base_url = base_url.strip() if base_url else \"\"\n    if cleaned_base_url:\n        entry[\"base_url\"] = cleaned_base_url\n    cleaned_project = project.strip() if project else \"\"\n    if cleaned_project:\n        # A project name is meaningful only for the LangSmith tracing service;\n        # enforce the invariant at the write boundary so a stray project can\n        # never be persisted onto an unrelated provider, regardless of caller.\n        # Lazy import avoids a circular dependency (model_config imports this\n        # module), matching the pattern in `auth_path`.\n        from deepagents_code.model_config import is_langsmith\n\n        if not is_langsmith(provider):\n            msg = f\"project is only valid for the langsmith service, not {provider!r}\"\n            raise ValueError(msg)\n        entry[\"project\"] = cleaned_project\n    creds[provider] = entry\n    data[\"version\"] = _STORAGE_VERSION\n    data[\"credentials\"] = creds\n    warnings = _write_raw_or_raise(data)\n    logger.debug(\"Stored credential for provider %s\", provider)\n    return WriteOutcome(warnings=warnings)\n\n\ndef delete_stored_key(provider: str) -> DeleteOutcome:\n    \"\"\"Remove a stored credential for `provider`.\n\n    Args:\n        provider: Provider identifier.\n\n    Returns:\n        A `DeleteOutcome` whose `removed` flag reports whether a credential was\n        present, and whose `warnings` tuple lists chmod failures from the","sourceCodeStart":481,"sourceCodeEnd":517,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/auth_store.py#L481-L517","documentation":"`set_stored_key` accepts an optional `project` field, but only for the LangSmith service. It lazily imports `is_langsmith` from model_config (avoiding a circular dependency) and raises `ValueError` if a `project` is supplied for any other provider, since non-LangSmith credentials have no project concept.","triggerScenarios":"Calling set_stored_key(provider, key, project=\"my-project\") where provider is not recognized by is_langsmith() — e.g. set_stored_key(\"anthropic\", key, project=\"x\").","commonSituations":"A generic config loader that passes project for every provider; copy-pasting LangSmith setup code for another provider; case/alias mismatch such as \"langsmith \" vs \"LangSmith\" if is_langsmith is exact-match.","solutions":["Omit the project argument for non-LangSmith providers: set_stored_key(\"anthropic\", key).","Use the exact provider identifier the library expects for LangSmith (verify what is_langsmith accepts) before passing project.","If you need to record project info for other providers, store it in your own config rather than the credential store."],"exampleFix":"// before\nset_stored_key(provider, key, project=project)  # provider=\"anthropic\" -> ValueError\n// after\nkwargs = {\"project\": project} if is_langsmith(provider) else {}\nset_stored_key(provider, key, **kwargs)","handlingStrategy":"validation","validationCode":"from deepagents_code.model_config import is_langsmith\ndef safe_set(provider: str, key: str, project: str | None = None) -> None:\n    if project and not is_langsmith(provider):\n        raise UsageError(f\"project applies only to langsmith, got {provider!r}\")\n    set_stored_key(provider, key, project=project)","typeGuard":"def _accepts_project(provider: str) -> TypeGuard[str]:\n    return is_langsmith(provider)","tryCatchPattern":"try:\n    set_stored_key(provider, key, project=project)\nexcept ValueError as exc:\n    if \"project is only valid for the langsmith service\" in str(exc):\n        set_stored_key(provider, key)  # retry without project\n    else:\n        raise","preventionTips":["Only pass `project` for providers that is_langsmith() accepts.","Match provider identifiers exactly as the library spells them (avoid aliases/case drift).","In generic config loaders, filter per-provider fields by provider type before mapping to set_stored_key kwargs.","Keep LangSmith configuration separate from model-provider credential flows."],"tags":["auth","validation","langsmith","argument-mismatch"],"backgroundTag":"invalid-argument-combination","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}