Skip to content

build_system builds the validator's memory out of another instance's class #14

Description

@12yuens2

build_system builds the validator's memory out of another instance's class

tech-debt · raised in review of PR #7

build_system gives the validator its own memory by reaching into the class of the instance it was handed:

self.meta_memory_validator = mas_memory.__class__(
    namespace=mas_memory.namespace + "_validator",
    global_config=mas_memory.global_config,
    llm_model=mas_memory.llm_model,
    embedding_func=mas_memory.embedding_func,
)

It works, and Phase 4 relies on it — the memory modules carry their prompts as class attributes precisely so this reconstruction keeps them, which is why a functools.partial registry would have been silently broken. But a workflow reconstructing a collaborator by unpicking one it was given is the wrong direction of control: build_system has to know every constructor argument MASMemoryBase takes, and gains a reason to change every time that signature does.

Two ways out.

  1. build_mas supplies both. It already builds the memory module from module_map, so it can build a second one and pass it in. build_system's signature grows an optional validator_memory, and the workflow stops knowing how memories are made.
  2. The memory offers it. A MASMemoryBase.for_namespace(suffix) returning a sibling instance keeps the knowledge of its own constructor where it belongs, and reads as one line at the call site.

Option 2 is smaller and puts the knowledge in the right place. Option 1 is more thorough and fits the dependency direction the rest of Phase 4 moved toward.

Not urgent. test_a_rebuilt_memory_keeps_its_prompts pins the behaviour either way, so this can be changed without guessing.


Migrated from docs/BACKLOG.md.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    tech-debtRefactor / debt cleanup, not a behaviour bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions