agentscope-ai / agentscope-ai/agentscope-java

[Feature]: Support Placeholde between Agents in Pipeline

未关闭
#545 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
area/core/agent enhancement
主要语言
Java
星标
5.6k
派生
1.3k
平均合并
4 天 12 小时
30 天内合并 PR
77

描述

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

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。