HKUDS/Vibe-Trading · error · TypeError
build_comps_artifact: result must be a CompsResult, got {typ
Error message
build_comps_artifact: result must be a CompsResult, got {type(result).__name__} What it means
build_comps_artifact requires result to be a CompsResult instance, mirroring the DCF variant. Anything else (dict, DCFResult, raw multiples table) raises a TypeError before any hashing happens.
Source
Thrown at agent/src/quantlib/valuation/artifact.py:808
Args:
target: The :class:`TargetCompany` passed to ``run_comps``.
peers: The peer sequence passed to ``run_comps``.
calendarisation_policy: The ``calendarisation_policy`` the call used.
result: The :class:`CompsResult` that call produced.
generated_at: Timezone-aware timestamp of the run, supplied by the
caller.
Returns:
A ``model_name="comps"`` :class:`ModelArtifact`.
Raises:
TypeError: If ``generated_at`` is not a ``datetime``, or ``result``
is not a :class:`CompsResult`.
ValueError: If ``generated_at`` is timezone-naive.
"""
generated_at = _require_generated_at(generated_at, "build_comps_artifact")
if not isinstance(result, CompsResult):
raise TypeError(
f"build_comps_artifact: result must be a CompsResult, got {type(result).__name__}"
)
canonical_inputs = {
"config": {"calendarisation_policy": calendarisation_policy},
"target": target,
"peers": list(peers),
}
hash_leaves: dict[str, str] = {}
readable_inputs: dict[str, Any] = {}
_flatten(canonical_inputs, "$", hash_leaves, readable_inputs, None)
input_hash = _hash_leaves(hash_leaves)
readable_outputs: dict[str, Any] = {}
assumptions: list[AssumptionRecord] = []
_flatten(result, "$", {}, readable_outputs, assumptions)
return ModelArtifact(View on GitHub (pinned to 80ffdda44c)
Solutions
- Pass the CompsResult returned by run_comps(...).
- Re-export or re-wrap your data into a CompsResult before artifact creation.
- Check for duplicate/stale CompsResult definitions on the import path.
Example fix
# before build_comps_artifact(result=peer_table_df, generated_at=ts) # after build_comps_artifact(result=run_comps(target, peers), generated_at=ts)
Defensive patterns
Strategy: type-guard
Validate before calling
from quantlib.valuation.models import CompsResult
assert isinstance(result, CompsResult), f"expected CompsResult, got {type(result).__name__}" Type guard
from quantlib.valuation.models import CompsResult
def is_comps_result(value) -> bool:
return isinstance(value, CompsResult) Prevention
- Pass run_comps(...) output straight through.
- Check for stale duplicate CompsResult classes after refactors.
When it happens
Trigger: build_comps_artifact(result=df_of_multiples, ...); passing the output of run_dcf or a plain dict; feeding a dataclass from an older version of the comps module.
Common situations: Model refactor changing run_comps' return type; mixing up build_*_artifact calls when copy-pasting; stale imports shadowing CompsResult.
Understand the failure class
Background: "Wrong argument type", "must be a string", "expected Array or Prism::Scope": TypeError and ArgumentError when a library receives a value of the wrong type — this error's family across 28 libraries.
Related errors
- {model}: generated_at must be a datetime.datetime supplied b
- build_dcf_artifact: result must be a DCFResult, got {type(re
- build_three_statement_artifact: result must be a ThreeStatem
- amount must be numeric, got {self.amount!r}
- metadata must be a mapping, got {type(self.metadata).__name_
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/6e2ee4fecc37c88b.
Report an issue: GitHub.