Skip to content

Investigate reducing deepcopies in Agent #10680

@anakin87

Description

@anakin87

While reviewing deepcopy usage in Pipeline, I've also seen several deepcopies in Agent.
Worth investigating if they can be safely removed/handled differently for performance reasons.

  1. agent_inputs span tags

    with self._create_agent_span() as span:
    span.set_content_tag("haystack.agent.input", _deepcopy_with_exceptions(agent_inputs))

    Apparently agent_inputs is created here and used for the span tag only. If that's the case, no need to deepcopy it.

  2. state_schema

    resolved_state_schema = _deepcopy_with_exceptions(self._state_schema)

    The goal seems to keep self._state_schema and self.state_schema separate. Would a shallow dict() copy be sufficient?

Metadata

Metadata

Assignees

Labels

P2Medium priority, add to the next sprint if no P1 available

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions