agentscope-ai / agentscope-ai/agentscope-java

[Feature]: Support Placeholde between Agents in Pipeline

Abierto
#545 0 comentarios 0 reacciones 0 asignados Ver en GitHub
area/core/agent enhancement
Lenguaje dominante
Java
Estrellas
5.6k
Forks
1.3k
Merge medio
4 d 12 h
PR fusionados (30 d)
77

Descripción

**AgentScope-Java is an open-source project. To involve a broader community, we recommend asking your questions in English.**

**Is your feature request related to a problem? Please describe.**
Currently, in SequentialPipeline, each agent automatically receives the raw output of the previous agent as its entire input. While this works for simple linear workflows, it becomes limiting when a downstream agent needs to:
- Combine the original user input with the previous agent’s output
- Embed the previous agent’s output into a structured prompt
- Reference multiple upstream outputs in a controlled or formatted way

At the moment, AgentScope-Java does not support placeholders or explicit output injection, so developers cannot easily construct prompts like:

“Based on the researcher’s findings below, and the original topic, write a summary…”

This forces users to manually wrap logic outside the pipeline, or use `systemMessage`

Both approaches reduce readability and defeat the purpose of pipelines as a high-level orchestration abstraction.

**Describe the solution you'd like**

I would like AgentScope-Java to support placeholders (or explicit output references) that allow a downstream agent to use previous agents’ outputs as part of its input, rather than replacing the entire input.

For example, in a SequentialPipeline:

User Input → Researcher → Writer → Editor

The Writer agent should be able to receive a prompt such as:
```text
Original Topic:
{{input}}

Research Findings:
{{output:Researcher}}
```

Possible design options:
**(1) Placeholder-based prompt templating**
Support placeholders in agent instructions, allowing downstream agents to reference outputs from previous agents in the pipeline. For example:
```java
ReActAgent researcher = ReActAgent.builder()
.name("Researcher")
.sysPrompt("You are a researcher. Analyze the topic and provide key findings.")
.model(model)
.outputKey("research")
.build();

ReActAgent writer = ReActAgent.builder()
.name("Writer")
.sysPrompt("You are a writer. Write a concise summary based on the research findings.")
.model(model)
.outputKey("writer")
.build();

ReActAgent editor = ReActAgent.builder()
.name("Editor")
.sysPrompt("You are an editor. Polish and finalize the summary.")
.instruction(
"Original topic:\n" +
"{{research}}\n\n" +
"Summary of research findings:\n" +
"{{writer}}"
)
.model(model)
.build();
```

This approach allows agent instructions to dynamically include outputs from earlier agents using placeholders such as {{research}} and {{writer}}.

**(2) Provide a PipelineMessageContext for pipelines**
Introduce a PipelineMessageContext that stores the outputs of all agents executed within the current pipeline. Downstream agents (or pipeline-level input builders) can freely access any previous agent’s output through this context, enabling more flexible and explicit composition of agent inputs.

This would greatly improve expressiveness for multi-agent workflows such as research → synthesis → editing, without breaking existing APIs.

**Describe alternatives you've considered**
None

**Additional context**
Example from https://java.agentscope.io/zh/multi-agent/pipeline.html

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.