agentos-project/agentos

Comparing specs using `==` is incorrect sometimes

Opened this issue · 0 comments

andyk commented

We currently use == in to_registry() on many spec classes such as here in ComponentRun.to_registry():

assert spec == self.to_spec(), (
f"A component run spec with identifier '{self.identifier}' "
f"already exists in registry '{registry}' and differs from "
"the one being added. Use force=True to overwrite the "
"existing one."
)

This can be wrong because currently some fields in specs can be omitted when their values are None. E.g., the WebRegistry always returns an agent and environment field for ComponentRun specs, even when the value of those attributes is None.

Essentially, we currently allow any optional spec field to be either omitted from the spec OR included and set to None.

Since {x: None} == {} returns False in Python (and rightfully so!) we need a smarter way of testing specs for equality.

We should be using a hash of the specs, and in fact the identifier should probably be the hash for all spec types (as it is currently for ArgumentSet specs). This should be addressed by #253, which will probably be done as part of #250.