agentscope-ai / agentscope-ai/agentscope-java

[Feature]: Support Placeholde between Agents in Pipeline

Đang mở
#545 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
area/core/agent enhancement
Ngôn ngữ chính
Java
Star
5.6k
Fork
1.3k
Merge trung bình
4 ngày 12 giờ
Pull request đã merge (30 ngày)
77

Mô tả

**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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.